diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100755 index be742e6a8..000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,40 +0,0 @@ -# iOS CircleCI 2.0 configuration file -# -# Check https://circleci.com/docs/2.0/ios-migrating-from-1-2/ for more details -# -version: 2 -jobs: - build: - - # Specify the Xcode version to use - macos: - xcode: "9.3" - - steps: - - checkout - - # Install CocoaPods - - run: - name: Install CocoaPods - command: pod install - - # Build the app and run tests - - run: - name: Build and run tests - command: fastlane scan - environment: - SCAN_DEVICE: iPhone 6 - SCAN_SCHEME: WebTests - - # Collect XML test results data to show in the UI, - # and save the same XML files under test-results folder - # in the Artifacts tab - - store_test_results: - path: test_output/report.xml - - store_artifacts: - path: /tmp/test-results - destination: scan-test-results - - store_artifacts: - path: ~/Library/Logs/scan - destination: scan-logs - diff --git a/.codespellrc b/.codespellrc new file mode 100644 index 000000000..60cba01f6 --- /dev/null +++ b/.codespellrc @@ -0,0 +1,4 @@ +[codespell] +count = True +ignore-words-list = ans,deriver,inout,packag +skip = *.js,*.h,*.c,*WordLists.swift,.git,Carthage,.build,build diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 000000000..f1f7a584d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,67 @@ +name: Bug Report +description: File a bug report. +labels: ['bug'] +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out this bug report! + - type: textarea + id: bug-description + attributes: + label: What happened? + description: Please describe the bug. + placeholder: Description of the bug. + validations: + required: true + - type: textarea + id: steps-to-reproduce + attributes: + label: What are the steps to reproduce? + description: Please describe the steps to reproduce the bug. + placeholder: | + Step 1: ... + Step 2: ... + Step 3: ... + validations: + required: true + - type: textarea + id: expected-behavior + attributes: + label: What is the expected behavior? + description: Please describe the behavior you expect. + placeholder: I expect that... + validations: + required: true + - type: textarea + id: error-thrown + attributes: + label: What is the error thrown? + description: Please provide the exact error thrown. + placeholder: Web3Error.invalidData("Exact error message") + validations: + required: true + - type: textarea + id: source-path + attributes: + label: What's the stack trace said? + description: Please provide the exact source path. + placeholder: Sources/Core/Transaction/CodableTransaction.swift:129 func recoverPublicKey() + validations: + required: true + - type: textarea + id: os-version + attributes: + label: OS version + description: Please specify what platform and os version you are using? + placeholder: macOS 13.0.1 (22A400) + validations: + required: true + - type: textarea + id: lib-version + attributes: + label: Library version + description: Please specify what library version you are using? + placeholder: 3.0.6 or "ef06fbfc735ab687ebf89c937a9d1ffe6d81d37f" commit. + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/documentation-request.yml b/.github/ISSUE_TEMPLATE/documentation-request.yml new file mode 100644 index 000000000..c6af21ffe --- /dev/null +++ b/.github/ISSUE_TEMPLATE/documentation-request.yml @@ -0,0 +1,24 @@ +name: Documentation Request +description: Suggest documentation you would like added +labels: ['documentation'] +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out this documentation request! + - type: textarea + id: area + attributes: + label: What piece of the framework are having the lack of docs? + description: Bring the link, either type, either method name that is having the lack of docs + placeholder: "`Sources/Core/EthereumABI.swift:ABIElementPropertiesProtocol` or `ABIElementPropertiesProtocol`" + validations: + required: true + - type: textarea + id: reason + attributes: + label: What bit of docs would you like to have? + description: A clear and concise description of why this documentation needs to be improved. + placeholder: There's a lack of docs that covers both the intent of this type and the way how it should be used within client code. + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 000000000..a3bd3a54e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,30 @@ +name: Feature Request +description: Suggest an idea for this project +labels: ['enhancement'] +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out this feature request! + - type: textarea + id: problem + attributes: + label: What context is your feature request related to? + description: Short context name, please do not overcomplicate neither over fractionize it. + placeholder: Transaction pipeline enhancement, supported platform list extending, etc. + validations: + required: true + - type: textarea + id: solution + attributes: + label: What solution would you like? + description: A clear and concise description of what you want to happen. + placeholder: I would like that your lib has a magic "give me money" button, that provides me to just to build it, be uploaded to the AppStore and to get rich. + validations: + required: true + - type: textarea + id: context + attributes: + label: Any additional context? + description: If there's some specs either standard for such feature invented already here's the good place to provide those. + placeholder: Here's the pictures of house that i'd wanted to be able to bough after i've got rich and the my future cars list as well. diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 000000000..1f4c26e96 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,13 @@ +## **Summary of Changes** + +Fixes # _(if applicable - add the number of issue this PR addresses)_ + +## **Test Data or Screenshots** + +###### _By submitting this pull request, you are confirming the following:_ + +- I have reviewed the [Contribution Guidelines](https://github.com/web3swift-team/web3swift/blob/develop/CONTRIBUTION.md). +- I have performed a self-review of my own code. +- I have updated my repository to match the `develop` branch. +- I have included test data or screenshots that prove my fix is effective or that my feature works. +- I have checked that all tests work and swiftlint is not throwing any errors/warnings. diff --git a/.github/workflows/macOS-tests.yml b/.github/workflows/macOS-tests.yml new file mode 100644 index 000000000..2e5aac32b --- /dev/null +++ b/.github/workflows/macOS-tests.yml @@ -0,0 +1,61 @@ +name: "macOS 13" + +on: + push: + branches: + - master + - develop + - hotfix + paths: + - Packag*.swift + - web3swift.podspec + - Cartfile + - Sources/** + - 'Tests/**' + - 'web3swift*/**' + - '.github/workflows/**' + pull_request: + branches: + - master + - develop + - unstable + # Temporary develop-X.Y.Z branches may be added and removed from here as we release new versions + - develop-4.0 + +env: + DEVELOPER_DIR: /Applications/Xcode_15.2.app/Contents/Developer + +jobs: + spm: + name: Swift Package Manager 5.9 + runs-on: macos-13 + concurrency: + group: spm-${{ github.run_id }} + cancel-in-progress: false + steps: + - uses: actions/checkout@v3 + - name: Discover typos + run: | + pipx install codespell + codespell # See .codespellrc for args + - name: SwiftLint + run: | + # 1. Make all automated fixes that are possible + # 2. git diff to see what (if any) automated fixes were made + # 3. See https://github.com/realm/SwiftLint#xcode explains why the double run + swiftlint --fix --quiet && git diff && swiftlint --quiet + - name: Install Foundry (includes anvil EVM) + run: | + curl -L https://foundry.paradigm.xyz | bash + source ~/.bashrc + foundryup + - name: Start anvil in background + run: ~/.foundry/bin/anvil -q & + - name: Resolve dependencies + run: swift package resolve + - name: Build + run: swift build --build-tests + - name: Run local tests + run: swift test --skip-build -c debug --filter localTests + - name: Run remote tests + run: swift test --skip-build -c debug --filter remoteTests diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 000000000..19c7b391b --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,22 @@ +# https://pre-commit.com +# This GitHub Action assumes that the repo contains a valid .pre-commit-config.yaml file. +# Using pre-commit.ci is even better than using GitHub Actions for pre-commit. +name: pre-commit +on: + pull_request: + branches: [develop] + push: + branches: [develop] + workflow_dispatch: +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: 3.x + - run: pip install pre-commit + - run: pre-commit --version + - run: pre-commit install + - run: pre-commit run --all-files diff --git a/.gitignore b/.gitignore index 1b8c7945d..2dd3e0601 100755 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,7 @@ ## Build generated build/ DerivedData/ -.build + ## Various settings *.pbxuser !default.pbxuser @@ -21,6 +21,7 @@ xcuserdata/ *.moved-aside *.xccheckout *.xcscmblueprint +web3swift.xcodeproj/ ## Obj-C/Swift specific *.hmap @@ -35,9 +36,12 @@ playground.xcworkspace # Swift Package Manager # # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. -# Packages/ -# Package.pins +Packages/ +Package.pins .build/ +.swiftpm/** +*/.swiftpm/** +Package.resolved # CocoaPods # @@ -45,15 +49,13 @@ playground.xcworkspace # you should judge for yourself, the pros and cons are mentioned at: # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control # -# Pods/ -# Example/web3swiftBrowser/Pods +Example/**/Pods # Carthage # # Add this line if you want to avoid checking in source code from Carthage dependencies. -# Carthage/Checkouts - -#Carthage/Build +Carthage/Checkouts +Carthage/Build # fastlane # diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..0b19196c4 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,22 @@ +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.2.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + - id: check-case-conflict + - id: check-json + - id: mixed-line-ending + - id: no-commit-to-branch + args: [--branch, staging, --branch, main, --branch, master, --branch, develop-4.0, --branch, develop-upstream] +- repo: https://github.com/codespell-project/codespell + rev: v2.2.2 + hooks: + - id: codespell # See .codespellrc for args +# - repo: https://github.com/realm/SwiftLint # Too slow in pre-commit +# rev: 0.50.3 +# hooks: +# - id: swiftlint +# args: [--fix, Sources, Tests] diff --git a/.swiftformat b/.swiftformat new file mode 100644 index 000000000..4e5ff917a --- /dev/null +++ b/.swiftformat @@ -0,0 +1,51 @@ +# rules +--enable isEmpty +--enable redundantFileprivate +--enable redundantReturn +--enable redundantBackticks +--enable redundantBreak +--enable redundantClosure +--enable redundantExtensionACL +--enable organizeDeclarations +--enable redundantFileprivate +--enable redundantGet +--enable redundantInit +--enable redundantInternal +--enable redundantLet +--enable redundantLetError +--enable redundantNilInit +--enable redundantObjc +--enable redundantOptionalBinding +--enable redundantParens +--enable redundantPattern +--enable redundantStaticSelf +--enable redundantVoidReturnType +--disable redundantRawValues +--disable sortImports +--disable andOperator +--disable wrapMultilineStatementBraces +--disable extensionAccessControl + +# format options +--indentcase true +--trimwhitespace nonblank-lines +--maxwidth 130 +--commas inline +--comments indent +--decimalgrouping 3,5 +--exponentcase lowercase +--exponentgrouping disabled +--extensionacl on-declarations +--fractiongrouping disabled +--ifdef no-indent +--importgrouping testable-top +--operatorfunc no-space +--nospaceoperators ..<, ... +--selfrequired validate +--stripunusedargs closure-only +--wraparguments preserve +--wrapcollections preserve +--wrapparameters preserve + +# organizeDeclarations +--markcategories false diff --git a/.swiftlint.yml b/.swiftlint.yml new file mode 100644 index 000000000..f7519e42f --- /dev/null +++ b/.swiftlint.yml @@ -0,0 +1,73 @@ +excluded: + - .build + - Build + - Carthage + - DerivedData + - Pods + +analyzer_rules: + - unused_import + +disabled_rules: + - block_based_kvo + - closure_body_length + - computed_accessors_order + - cyclomatic_complexity + - duplicate_imports + - empty_enum_arguments + - empty_string + - file_length + - for_where + - force_cast + - force_try + - force_unwrapping + - function_body_length + - function_parameter_count + - identifier_name + - implicit_getter + - implicitly_unwrapped_optional + - indentation_width + - large_tuple + - legacy_objc_type + - line_length + - multiple_closures_with_trailing_closure + - nesting + - orphaned_doc_comment + - operator_whitespace + - return_arrow_whitespace + - shorthand_operator + - todo + - trailing_closure + - type_body_length + - type_name + - unneeded_break_in_switch + - unused_optional_binding + - vertical_parameter_alignment + - xctfail_message + +opt_in_rules: + - closure_body_length + - empty_string + - fallthrough + - force_unwrapping + - implicitly_unwrapped_optional + - indentation_width + - legacy_objc_type + - override_in_extension + - redundant_nil_coalescing + - static_operator + - trailing_closure + - unneeded_parentheses_in_closure_argument + - weak_delegate + +custom_rules: + commented_out_code: + included: .*\.swift # regex that defines paths to include during linting. optional. + excluded: .*Test(s)?\.swift # regex that defines paths to exclude during linting. optional + name: Commented out code # rule name. optional. + regex: ^\s*(\/\/(?!\s*swiftlint:).*|\/\*[\s\S]*?\*\/) # matching pattern + capture_group: 0 # number of regex capture group to highlight the rule violation at. optional. + match_kinds: # SyntaxKinds to match. optional. + - comment + message: No commented code in devel branch allowed. # violation message. optional. + severity: warning # violation severity. optional. diff --git a/.travis.yml b/.travis.yml deleted file mode 100755 index 2ccd46853..000000000 --- a/.travis.yml +++ /dev/null @@ -1,15 +0,0 @@ -language: swift -osx_image: xcode10.2 -cache: bundler -xcode_project: web3swift.xcworkspace -xcode_scheme: web3swift-iOS -xcode_destination: platform=iOS Simulator, OS=12.2, name=iPhone X -#before_install: -# - brew install carthage || true -# - brew outdated carthage || brew upgrade carthage -#before_script: -# - carthage bootstrap --platform iOS --no-use-binaries --cache-builds -script: - - xcodebuild -scheme web3swift -project web3swift.xcodeproj -sdk iphonesimulator build test -after_success: - - bash <(curl -s https://codecov.io/bash) diff --git a/CHANGELOG.md b/CHANGELOG.md index 901774947..b477f29d7 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,428 +1,777 @@ # Changelog -## [Unreleased](https://github.com/matter-labs/web3swift/tree/HEAD) +## [2.6.5](https://github.com/skywinder/web3swift/tree/2.6.5) (2022-05-26) -[Full Changelog](https://github.com/matter-labs/web3swift/compare/2.3.0...HEAD) +- correct the decoding key for from in transactionOptions by @mloit in #570 + +## [2.6.4](https://github.com/skywinder/web3swift/tree/2.6.4) (2022-05-06) + +- Fix ERC-1155 ABI by @mloit in #557 +- Fix access level for EIP-712 related objects by @mloit in #555 +- Restore public API fromJSON() functions by @mloit in #558 + +## [2.6.3](https://github.com/skywinder/web3swift/tree/2.6.3) (2022-04-27) + +- Feature/automatic gas 1559 by @mloit in #547 +- Oracle.suggestGasFeeLegacy method fixup by @yaroslavyaroslav in #551 + +## [2.6.2](https://github.com/skywinder/web3swift/tree/2.6.2) (2022-04-25) + +- Fix #540 by freezing CryptoSwift dependency to last working version (1.4.3) by @yaroslavyaroslav + +## [2.6.1](https://github.com/skywinder/web3swift/tree/2.6.1) (2022-04-19) + +- Update documentation for EIP-1559 support by @mloit in #530 +- Feature/transaction metadata by @mloit in #523 + +## [2.6.0](https://github.com/skywinder/web3swift/tree/2.6.0) (2022-04-15) + +### Features + +- Add full EIP-1559 transaction support see +- Add gas prediction support see + +### What's Changed + +- Remove BrowserViewController if building for anything other than iOS by @mloit in #503 +- Feature/pre swiftlint cleanup by @mloit in #495 +- Feature/late lint fixups by @mloit in #508 +- Fix Base58 Decoding by @mloit in #504 +- Swiftlint by @mloit in #499 +- ERC1155: Change access control for Interfece-based methods. by @mrklos in #494 +- feat: solidity sha3 implementation added by @JeneaVranceanu in #506 +- add indentation check [default is 4 spaces per tab-stop] by @mloit in #512 +- EIP-1559 support release by @yaroslavyaroslav in #510 +- EIP-1559 Gas prediction implementation by @yaroslavyaroslav in #513 +- feat: decoding ABI with solidity error types by @JeneaVranceanu in #455 +- Gas prediction implementation by @yaroslavyaroslav in #514 +- Bug fix/transaction index by @mloit in #521 +- EIP-1559 transaction support by @mloit in #509 +- Full Changelog: 2.5.1...2.6.0 + +## [2.5.1](https://github.com/skywinder/web3swift/tree/2.5.1) (2022-03-23) + +- Drop Carthage cache files by yaroslavyaroslav +- Drop examples cocoapods cache files by yaroslavyaroslav +- Improve ci/cd pipeline by adding localTests job by yaroslavyaroslav +- Rename tests in swift style name convention (CamelCase) by yaroslavyaroslav +- Enable run ganache util in ci/cd pipeline (required for local tests) by yaroslavyaroslav +- Clear lib warnings on build #437 by Valter4578 & mliot +- Change UINT64_MAX to UInt64.max by mloit +- Update CHANGELOG.md by ZeroCode999 +- Fix tokenURI method name for ERC721 and ERC721x tokens #419 by Sarquella +- Provide basic tolerance to EIP-1559 data by mloit +- Fix for buffer overflow in [Data|SECP256K1].randomBytes() #470 by mloit +- Arbitrary clean project code by mloit +- Fix github actions config issue that occasionally cancels running jobs by yaroslavyaroslav +- mini-rollup of several issues by mloit + +## [2.5.0](https://github.com/skywinder/web3swift/tree/2.5.0) (2021-12-23) + +[Full Changelog](https://github.com/skywinder/web3swift/compare/2.3.0...2.5.0) **Implemented enhancements:** -- Credentials: send "Authorization" header [\#267](https://github.com/matter-labs/web3swift/issues/267) +- Add support of EIP-712 signatures [\#323](https://github.com/skywinder/web3swift/issues/323) +- BIP39.mnemonicsToEntropy does not work for mnemonics of length 15, 18, 21 [\#300](https://github.com/skywinder/web3swift/issues/300) +- Support Solidity 0.6 & ABIEncoderV2 [\#258](https://github.com/skywinder/web3swift/issues/258) +- Omit zeros at the end of formatted string [\#117](https://github.com/skywinder/web3swift/issues/117) +- \[recreated\] Detect read function aborting by messaged require statement [\#276](https://github.com/skywinder/web3swift/pull/276) ([hakumai-iida](https://github.com/hakumai-iida)) + +**Fixed bugs:** + +- `subscribeOnLogs` method with specific contract address is not working!!!! [\#366](https://github.com/skywinder/web3swift/issues/366) +- EthereumContract with Custom ABI returns nil [\#342](https://github.com/skywinder/web3swift/issues/342) +- Error on running tests [\#290](https://github.com/skywinder/web3swift/issues/290) +- Serialisation of BIP32 misplaced address position [\#257](https://github.com/skywinder/web3swift/issues/257) +- Xcode 10.2.1 carthage update hangs while building web3swift.xcodeproj [\#197](https://github.com/skywinder/web3swift/issues/197) **Closed issues:** -- Xcode 10.3 archive failed [\#266](https://github.com/matter-labs/web3swift/issues/266) -- Xcode 11 regenerating password [\#228](https://github.com/matter-labs/web3swift/issues/228) -- support Xocde 11 SPM for iOS [\#221](https://github.com/matter-labs/web3swift/issues/221) +- Error in Documentation Examples: "Failed to fetch gas estimate" [\#421](https://github.com/skywinder/web3swift/issues/421) +- BSC Network Transaction [\#418](https://github.com/skywinder/web3swift/issues/418) +- How to sign and send ERC20 token [\#413](https://github.com/skywinder/web3swift/issues/413) +- Example [\#409](https://github.com/skywinder/web3swift/issues/409) +- How install for macOS? [\#408](https://github.com/skywinder/web3swift/issues/408) +- Use case for Web3Swift [\#405](https://github.com/skywinder/web3swift/issues/405) +- Make and example on how to use ENS domains [\#404](https://github.com/skywinder/web3swift/issues/404) +- Make an example on how to check your wallet balance [\#402](https://github.com/skywinder/web3swift/issues/402) +- Implement a functionality to add custom chains [\#401](https://github.com/skywinder/web3swift/issues/401) +- Prepare and example on how to use mnemonics [\#399](https://github.com/skywinder/web3swift/issues/399) +- Expired Discord invitation link [\#382](https://github.com/skywinder/web3swift/issues/382) +- How to estimate gas limit and gas price ? [\#380](https://github.com/skywinder/web3swift/issues/380) +- let block = try? web3.eth.getBlockNumber\(\) [\#376](https://github.com/skywinder/web3swift/issues/376) +- Support carthage both M1 and Intel processors [\#375](https://github.com/skywinder/web3swift/issues/375) +- Support for Xcode 12 SPM [\#373](https://github.com/skywinder/web3swift/issues/373) +- promisekit: warning: `wait()` called on main thread! [\#372](https://github.com/skywinder/web3swift/issues/372) +- How to generate web3swift framework file from source [\#369](https://github.com/skywinder/web3swift/issues/369) +- how to maintain multiple wallet ,need to store separate key json file? [\#367](https://github.com/skywinder/web3swift/issues/367) +- Extremely slow init BIP39 and keystore in current dev branch [\#365](https://github.com/skywinder/web3swift/issues/365) +- How can i get EventLogs and topics from a transaction response? [\#359](https://github.com/skywinder/web3swift/issues/359) +- Cannot parse ABI with tuple\[\] [\#358](https://github.com/skywinder/web3swift/issues/358) +- Send Transaction issue, processingError\(desc: "Failed to fetch gas estimate"\) [\#356](https://github.com/skywinder/web3swift/issues/356) +- Instance member 'contract' cannot be used on type 'web3'; did you mean to use a value of this type instead? [\#352](https://github.com/skywinder/web3swift/issues/352) +- Could not build Objective-C module 'web3swift' [\#344](https://github.com/skywinder/web3swift/issues/344) +- Building the latest web3Swift example [\#341](https://github.com/skywinder/web3swift/issues/341) +- cannot open https://exchange.pancakeswap.finance/\#/swap [\#338](https://github.com/skywinder/web3swift/issues/338) +- Crash with parsing custom ABI Contract [\#333](https://github.com/skywinder/web3swift/issues/333) +- @ravi-ranjan-oodles thanks for the update. [\#329](https://github.com/skywinder/web3swift/issues/329) +- Issue in Uploading to Test Flight [\#328](https://github.com/skywinder/web3swift/issues/328) +- Update CryptoSwift podspec [\#322](https://github.com/skywinder/web3swift/issues/322) +- can't open DApp, such as "https://uniswap.tokenpocket.pro/\#/swap" [\#321](https://github.com/skywinder/web3swift/issues/321) +- CryptoSwift version is too low to work properly in Xcode12.5 [\#318](https://github.com/skywinder/web3swift/issues/318) +- web3swift.Web3Error.processingError\(desc: "Failed to fetch gas estimate"\)(BSC Chain) [\#317](https://github.com/skywinder/web3swift/issues/317) +- Quick simple steps for minting ERC20 or ERC721 tokens [\#314](https://github.com/skywinder/web3swift/issues/314) +- Generate Contract Bytecode / Address [\#313](https://github.com/skywinder/web3swift/issues/313) +- I can't find func 'Web3.InfuraKovanWeb3\(\)' [\#311](https://github.com/skywinder/web3swift/issues/311) +- web3 instance error: Variable used within its own initial value [\#310](https://github.com/skywinder/web3swift/issues/310) +- Failed to fetch gas estimate when sending erc20 [\#307](https://github.com/skywinder/web3swift/issues/307) +- DApp browser can't open Uniswap in a right way [\#304](https://github.com/skywinder/web3swift/issues/304) +- Update cocoapods bigint to 5.0 [\#288](https://github.com/skywinder/web3swift/issues/288) +- When I use getBlockByNumber , hash Unable to check [\#287](https://github.com/skywinder/web3swift/issues/287) +- How to parse the return value of read transaction [\#284](https://github.com/skywinder/web3swift/issues/284) +- Failed to fetch gas estimate [\#283](https://github.com/skywinder/web3swift/issues/283) +- Generic parameter 'Element' could not be inferred [\#282](https://github.com/skywinder/web3swift/issues/282) +- Unable to send ether using send function [\#279](https://github.com/skywinder/web3swift/issues/279) +- This request is not supported because your node is running with state pruning. Run with --pruning=archive. [\#274](https://github.com/skywinder/web3swift/issues/274) +- Send ERC20 token error And get token name error [\#262](https://github.com/skywinder/web3swift/issues/262) +- Problem when decoding raw transaction input data [\#216](https://github.com/skywinder/web3swift/issues/216) +- Is it necessary to use password in creating Bip32keystore ? [\#213](https://github.com/skywinder/web3swift/issues/213) + +**Merged pull requests:** -## [2.3.0](https://github.com/matter-labs/web3swift/tree/2.3.0) (2020-09-21) +- Fix-up [\#427](https://github.com/skywinder/web3swift/pull/427) ([yaroslavyaroslav](https://github.com/yaroslavyaroslav)) +- 2.5.0 [\#426](https://github.com/skywinder/web3swift/pull/426) ([yaroslavyaroslav](https://github.com/yaroslavyaroslav)) +- Bugfix: Derive PublicKey [\#423](https://github.com/skywinder/web3swift/pull/423) ([yuzhiyou1990](https://github.com/yuzhiyou1990)) +- Enabling GitHub actions [\#422](https://github.com/skywinder/web3swift/pull/422) ([yaroslavyaroslav](https://github.com/yaroslavyaroslav)) +- Fix building issue [\#410](https://github.com/skywinder/web3swift/pull/410) ([yaroslavyaroslav](https://github.com/yaroslavyaroslav)) +- Fixed keystore backward compatibility [\#397](https://github.com/skywinder/web3swift/pull/397) ([BaldyAsh](https://github.com/BaldyAsh)) +- add support of EIP-712 signature [\#396](https://github.com/skywinder/web3swift/pull/396) ([BaldyAsh](https://github.com/BaldyAsh)) +- Fix ENS.getContentHash to return Data [\#395](https://github.com/skywinder/web3swift/pull/395) ([battlmonstr](https://github.com/battlmonstr)) +- Fix Serialisation of BIP32 Keystore [\#394](https://github.com/skywinder/web3swift/pull/394) ([BaldyAsh](https://github.com/BaldyAsh)) +- Dependency update | M1 support [\#389](https://github.com/skywinder/web3swift/pull/389) ([Valter4578](https://github.com/Valter4578)) +- Fixed typo in function name [\#386](https://github.com/skywinder/web3swift/pull/386) ([JeneaVranceanu](https://github.com/JeneaVranceanu)) +- Updated Example and Updated Version for BigInt , CryptoSwift and PromiseKit dependency [\#383](https://github.com/skywinder/web3swift/pull/383) ([veerChauhan](https://github.com/veerChauhan)) +- add support of EIP-712 signature [\#381](https://github.com/skywinder/web3swift/pull/381) ([AndreyMaksimkin](https://github.com/AndreyMaksimkin)) +- fixed parsing of ABIs with tuples + wrong gas info when transactionOptions created from json [\#379](https://github.com/skywinder/web3swift/pull/379) ([izakpavel](https://github.com/izakpavel)) +- fixed: websocket delegate issue \(new\) [\#378](https://github.com/skywinder/web3swift/pull/378) ([amirhossein7](https://github.com/amirhossein7)) +- Added Promise: Support for getCode function [\#368](https://github.com/skywinder/web3swift/pull/368) ([SwiftyLimi](https://github.com/SwiftyLimi)) +- Added: Receive type at ABI.Element [\#348](https://github.com/skywinder/web3swift/pull/348) ([SwiftyLimi](https://github.com/SwiftyLimi)) +- Update local Tests and refactoring [\#347](https://github.com/skywinder/web3swift/pull/347) ([BaldyAsh](https://github.com/BaldyAsh)) +- update carthage build scripts to support xcode 11-12 [\#345](https://github.com/skywinder/web3swift/pull/345) ([skywinder](https://github.com/skywinder)) +- Update libs versions, Cartfile and Pods dependencies [\#334](https://github.com/skywinder/web3swift/pull/334) ([AnnaYatsun1](https://github.com/AnnaYatsun1)) +- fix crash when 'payable' nil [\#332](https://github.com/skywinder/web3swift/pull/332) ([xdozorx](https://github.com/xdozorx)) +- Update README.md [\#331](https://github.com/skywinder/web3swift/pull/331) ([Iysbaera](https://github.com/Iysbaera)) +- CryptoSwift update version 1.4.0 [\#327](https://github.com/skywinder/web3swift/pull/327) ([lzttxs](https://github.com/lzttxs)) +- Update carthage libraries [\#325](https://github.com/skywinder/web3swift/pull/325) ([alex78pro](https://github.com/alex78pro)) +- Gas estimate fix [\#324](https://github.com/skywinder/web3swift/pull/324) ([frostiq](https://github.com/frostiq)) +- Update README.md [\#306](https://github.com/skywinder/web3swift/pull/306) ([manuG420](https://github.com/manuG420)) +- fix mnemonicsToEntropy mnemonic length check [\#301](https://github.com/skywinder/web3swift/pull/301) ([sche](https://github.com/sche)) +- Updated Contract transaction method with Your ABI string [\#299](https://github.com/skywinder/web3swift/pull/299) ([veerChauhan](https://github.com/veerChauhan)) +- fix crash abi parsing [\#296](https://github.com/skywinder/web3swift/pull/296) ([nerzh](https://github.com/nerzh)) +- Examples, Fixed Crashes, Refactoring [\#286](https://github.com/skywinder/web3swift/pull/286) ([skywinder](https://github.com/skywinder)) +- Master [\#281](https://github.com/skywinder/web3swift/pull/281) ([skywinder](https://github.com/skywinder)) +- Fix Serialisation of BIP32 Keystore [\#278](https://github.com/skywinder/web3swift/pull/278) ([podkovyrin](https://github.com/podkovyrin)) + +## [2.3.0](https://github.com/skywinder/web3swift/tree/2.3.0) (2020-09-26) + +[Full Changelog](https://github.com/skywinder/web3swift/compare/2.2.2...2.3.0) -[Full Changelog](https://github.com/matter-labs/web3swift/compare/2.2.2...2.3.0) +**Implemented enhancements:** + +- Credentials: send "Authorization" header [\#267](https://github.com/skywinder/web3swift/issues/267) **Fixed bugs:** -- How to add web3swift in my framework ? [\#167](https://github.com/matter-labs/web3swift/issues/167) -- Documentation link 404 in README.md [\#164](https://github.com/matter-labs/web3swift/issues/164) +- How to add web3swift in my framework ? [\#167](https://github.com/skywinder/web3swift/issues/167) +- Documentation link 404 in README.md [\#164](https://github.com/skywinder/web3swift/issues/164) **Closed issues:** -- web3swift.Web3Error.processingError\("Failed to fetch nonce"\) [\#272](https://github.com/matter-labs/web3swift/issues/272) -- WebView: Dapp & Connect Wallet [\#264](https://github.com/matter-labs/web3swift/issues/264) -- Create new contract method. [\#261](https://github.com/matter-labs/web3swift/issues/261) -- Not able to Deploy smart contract [\#214](https://github.com/matter-labs/web3swift/issues/214) -- unable to create archive file for testflight [\#161](https://github.com/matter-labs/web3swift/issues/161) +- web3swift.Web3Error.processingError\("Failed to fetch nonce"\) [\#272](https://github.com/skywinder/web3swift/issues/272) +- Xcode 10.3 archive failed [\#266](https://github.com/skywinder/web3swift/issues/266) +- WebView: Dapp & Connect Wallet [\#264](https://github.com/skywinder/web3swift/issues/264) +- Create new contract method. [\#261](https://github.com/skywinder/web3swift/issues/261) +- Xcode 11 regenerating password [\#228](https://github.com/skywinder/web3swift/issues/228) +- support Xocde 11 SPM for iOS [\#221](https://github.com/skywinder/web3swift/issues/221) +- Not able to Deploy smart contract [\#214](https://github.com/skywinder/web3swift/issues/214) +- unable to create archive file for testflight [\#161](https://github.com/skywinder/web3swift/issues/161) **Merged pull requests:** -- Added web3-react-native to libraries that use web3swift [\#263](https://github.com/matter-labs/web3swift/pull/263) ([cawfree](https://github.com/cawfree)) +- Added web3-react-native to libraries that use web3swift [\#263](https://github.com/skywinder/web3swift/pull/263) ([cawfree](https://github.com/cawfree)) -## [2.2.2](https://github.com/matter-labs/web3swift/tree/2.2.2) (2020-04-04) +## [2.2.2](https://github.com/skywinder/web3swift/tree/2.2.2) (2020-04-04) -[Full Changelog](https://github.com/matter-labs/web3swift/compare/2.2.1...2.2.2) +[Full Changelog](https://github.com/skywinder/web3swift/compare/2.2.1...2.2.2) **Implemented enhancements:** -- ENS Registry migration [\#237](https://github.com/matter-labs/web3swift/issues/237) -- WKWebView with injected "web3 [\#202](https://github.com/matter-labs/web3swift/issues/202) +- ENS Registry migration [\#237](https://github.com/skywinder/web3swift/issues/237) +- WKWebView with injected "web3 [\#202](https://github.com/skywinder/web3swift/issues/202) **Fixed bugs:** -- Fix build dependencies [\#244](https://github.com/matter-labs/web3swift/issues/244) -- Carthage build fails [\#226](https://github.com/matter-labs/web3swift/issues/226) +- Fix build dependencies [\#244](https://github.com/skywinder/web3swift/issues/244) +- Carthage build fails [\#226](https://github.com/skywinder/web3swift/issues/226) **Closed issues:** -- Event filters by Param not working [\#248](https://github.com/matter-labs/web3swift/issues/248) -- KeysService\(\) in Migration guide not found [\#240](https://github.com/matter-labs/web3swift/issues/240) -- How to get seed phrase from private key? [\#236](https://github.com/matter-labs/web3swift/issues/236) -- Sender Value nil [\#219](https://github.com/matter-labs/web3swift/issues/219) +- Event filters by Param not working [\#248](https://github.com/skywinder/web3swift/issues/248) +- KeysService\(\) in Migration guide not found [\#240](https://github.com/skywinder/web3swift/issues/240) +- How to get seed phrase from private key? [\#236](https://github.com/skywinder/web3swift/issues/236) +- Sender Value nil [\#219](https://github.com/skywinder/web3swift/issues/219) **Merged pull requests:** -- value as optional parameter [\#256](https://github.com/matter-labs/web3swift/pull/256) ([skywinder](https://github.com/skywinder)) -- 2.2.2 [\#253](https://github.com/matter-labs/web3swift/pull/253) ([BaldyAsh](https://github.com/BaldyAsh)) -- \#248 [\#250](https://github.com/matter-labs/web3swift/pull/250) ([hakumai-iida](https://github.com/hakumai-iida)) -- Baldyash/webview [\#249](https://github.com/matter-labs/web3swift/pull/249) ([BaldyAsh](https://github.com/BaldyAsh)) -- policy [\#247](https://github.com/matter-labs/web3swift/pull/247) ([BaldyAsh](https://github.com/BaldyAsh)) -- Fix dependencies, build [\#245](https://github.com/matter-labs/web3swift/pull/245) ([BaldyAsh](https://github.com/BaldyAsh)) -- chore: update ENS Registry migration [\#243](https://github.com/matter-labs/web3swift/pull/243) ([aranhaagency](https://github.com/aranhaagency)) -- improtant notice update [\#232](https://github.com/matter-labs/web3swift/pull/232) ([skywinder](https://github.com/skywinder)) -- Add Alice Wallet to project list [\#230](https://github.com/matter-labs/web3swift/pull/230) ([lmcmz](https://github.com/lmcmz)) -- Update Extensions.swift [\#225](https://github.com/matter-labs/web3swift/pull/225) ([kocherovets](https://github.com/kocherovets)) -- correct gasLimit [\#222](https://github.com/matter-labs/web3swift/pull/222) ([luqz](https://github.com/luqz)) -- Change BIP39 word list extension from array of strings to one string … [\#217](https://github.com/matter-labs/web3swift/pull/217) ([husamettinor](https://github.com/husamettinor)) -- Expose BIP39 words and separator [\#212](https://github.com/matter-labs/web3swift/pull/212) ([dawiddr](https://github.com/dawiddr)) +- value as optional parameter [\#256](https://github.com/skywinder/web3swift/pull/256) ([skywinder](https://github.com/skywinder)) +- 2.2.2 [\#253](https://github.com/skywinder/web3swift/pull/253) ([BaldyAsh](https://github.com/BaldyAsh)) +- \#248 [\#250](https://github.com/skywinder/web3swift/pull/250) ([hakumai-iida](https://github.com/hakumai-iida)) +- Baldyash/webview [\#249](https://github.com/skywinder/web3swift/pull/249) ([BaldyAsh](https://github.com/BaldyAsh)) +- policy [\#247](https://github.com/skywinder/web3swift/pull/247) ([BaldyAsh](https://github.com/BaldyAsh)) +- Fix dependencies, build [\#245](https://github.com/skywinder/web3swift/pull/245) ([BaldyAsh](https://github.com/BaldyAsh)) +- chore: update ENS Registry migration [\#243](https://github.com/skywinder/web3swift/pull/243) ([aranhaagency](https://github.com/aranhaagency)) +- important notice update [\#232](https://github.com/skywinder/web3swift/pull/232) ([skywinder](https://github.com/skywinder)) +- Add Alice Wallet to project list [\#230](https://github.com/skywinder/web3swift/pull/230) ([lmcmz](https://github.com/lmcmz)) +- Update Extensions.swift [\#225](https://github.com/skywinder/web3swift/pull/225) ([kocherovets](https://github.com/kocherovets)) +- correct gasLimit [\#222](https://github.com/skywinder/web3swift/pull/222) ([luqz](https://github.com/luqz)) +- Change BIP39 word list extension from array of strings to one string … [\#217](https://github.com/skywinder/web3swift/pull/217) ([husamettinor](https://github.com/husamettinor)) +- Expose BIP39 words and separator [\#212](https://github.com/skywinder/web3swift/pull/212) ([dawiddr](https://github.com/dawiddr)) -## [2.2.1](https://github.com/matter-labs/web3swift/tree/2.2.1) (2019-06-24) +## [2.2.1](https://github.com/skywinder/web3swift/tree/2.2.1) (2019-06-24) -[Full Changelog](https://github.com/matter-labs/web3swift/compare/2.2.0...2.2.1) +[Full Changelog](https://github.com/skywinder/web3swift/compare/2.2.0...2.2.1) **Implemented enhancements:** -- 2.2.0 [\#155](https://github.com/matter-labs/web3swift/issues/155) +- 2.2.0 [\#155](https://github.com/skywinder/web3swift/issues/155) **Closed issues:** -- BigInt 3.1 [\#207](https://github.com/matter-labs/web3swift/issues/207) -- recevied transaction id from geth node server but not able to see that transaction id at etherscan.io [\#200](https://github.com/matter-labs/web3swift/issues/200) -- How do I fetch information such as balance, decimal,symbol and name of ERC20token ? [\#199](https://github.com/matter-labs/web3swift/issues/199) -- Starscream 3.1.0 not compatible with Swift 5.0 [\#195](https://github.com/matter-labs/web3swift/issues/195) -- How to Connect infuraWebsocket and subsribe perticular event in swift? [\#193](https://github.com/matter-labs/web3swift/issues/193) -- Use of unresolved identifier 'Wallet' [\#192](https://github.com/matter-labs/web3swift/issues/192) -- V in Signed Message Hash not being calculated properly [\#191](https://github.com/matter-labs/web3swift/issues/191) -- Not possible to calculate fast, normal and cheap transaction fee ? [\#190](https://github.com/matter-labs/web3swift/issues/190) -- SocketProvider does not receive messages [\#188](https://github.com/matter-labs/web3swift/issues/188) -- Cannot build example in v2.1.6 [\#177](https://github.com/matter-labs/web3swift/issues/177) -- EIP67Code missing in web3swift 2.1.6 [\#176](https://github.com/matter-labs/web3swift/issues/176) -- 'internal' protection level on Web3Error description property [\#172](https://github.com/matter-labs/web3swift/issues/172) -- ENS initializer is inaccessible due to `internal` protection level [\#171](https://github.com/matter-labs/web3swift/issues/171) -- Archive on Xcode 10.2 [\#166](https://github.com/matter-labs/web3swift/issues/166) -- carthage not support on Xcode 10.2 [\#138](https://github.com/matter-labs/web3swift/issues/138) +- BigInt 3.1 [\#207](https://github.com/skywinder/web3swift/issues/207) +- received transaction id from geth node server but not able to see that transaction id at etherscan.io [\#200](https://github.com/skywinder/web3swift/issues/200) +- How do I fetch information such as balance, decimal,symbol and name of ERC20token ? [\#199](https://github.com/skywinder/web3swift/issues/199) +- Starscream 3.1.0 not compatible with Swift 5.0 [\#195](https://github.com/skywinder/web3swift/issues/195) +- How to Connect infuraWebsocket and subscribe particular event in swift? [\#193](https://github.com/skywinder/web3swift/issues/193) +- Use of unresolved identifier 'Wallet' [\#192](https://github.com/skywinder/web3swift/issues/192) +- V in Signed Message Hash not being calculated properly [\#191](https://github.com/skywinder/web3swift/issues/191) +- Not possible to calculate fast, normal and cheap transaction fee ? [\#190](https://github.com/skywinder/web3swift/issues/190) +- SocketProvider does not receive messages [\#188](https://github.com/skywinder/web3swift/issues/188) +- Cannot build example in v2.1.6 [\#177](https://github.com/skywinder/web3swift/issues/177) +- EIP67Code missing in web3swift 2.1.6 [\#176](https://github.com/skywinder/web3swift/issues/176) +- 'internal' protection level on Web3Error description property [\#172](https://github.com/skywinder/web3swift/issues/172) +- ENS initializer is inaccessible due to `internal` protection level [\#171](https://github.com/skywinder/web3swift/issues/171) +- Archive on Xcode 10.2 [\#166](https://github.com/skywinder/web3swift/issues/166) +- carthage not support on Xcode 10.2 [\#138](https://github.com/skywinder/web3swift/issues/138) **Merged pull requests:** -- 2.2.1 [\#210](https://github.com/matter-labs/web3swift/pull/210) ([BaldyAsh](https://github.com/BaldyAsh)) -- infura v3 complete update [\#209](https://github.com/matter-labs/web3swift/pull/209) ([BaldyAsh](https://github.com/BaldyAsh)) -- merge Master -\> develop [\#205](https://github.com/matter-labs/web3swift/pull/205) ([skywinder](https://github.com/skywinder)) -- update documentation, prettify doc style [\#204](https://github.com/matter-labs/web3swift/pull/204) ([skywinder](https://github.com/skywinder)) -- V handle fix [\#201](https://github.com/matter-labs/web3swift/pull/201) ([BaldyAsh](https://github.com/BaldyAsh)) -- Update ENSBaseRegistrar.swift [\#198](https://github.com/matter-labs/web3swift/pull/198) ([barrasso](https://github.com/barrasso)) -- Websockets improvements and fixes [\#189](https://github.com/matter-labs/web3swift/pull/189) ([BaldyAsh](https://github.com/BaldyAsh)) -- Update ETHRegistrarController.swift [\#187](https://github.com/matter-labs/web3swift/pull/187) ([barrasso](https://github.com/barrasso)) -- Update ETHRegistrarController.swift [\#183](https://github.com/matter-labs/web3swift/pull/183) ([barrasso](https://github.com/barrasso)) -- Fix typo in Usage [\#182](https://github.com/matter-labs/web3swift/pull/182) ([sweepty](https://github.com/sweepty)) -- Expose errorDescription. [\#181](https://github.com/matter-labs/web3swift/pull/181) ([andresousa](https://github.com/andresousa)) -- Update ENS Resolver [\#180](https://github.com/matter-labs/web3swift/pull/180) ([barrasso](https://github.com/barrasso)) +- 2.2.1 [\#210](https://github.com/skywinder/web3swift/pull/210) ([BaldyAsh](https://github.com/BaldyAsh)) +- infura v3 complete update [\#209](https://github.com/skywinder/web3swift/pull/209) ([BaldyAsh](https://github.com/BaldyAsh)) +- merge Master -\> develop [\#205](https://github.com/skywinder/web3swift/pull/205) ([skywinder](https://github.com/skywinder)) +- update documentation, prettify doc style [\#204](https://github.com/skywinder/web3swift/pull/204) ([skywinder](https://github.com/skywinder)) +- V handle fix [\#201](https://github.com/skywinder/web3swift/pull/201) ([BaldyAsh](https://github.com/BaldyAsh)) +- Update ENSBaseRegistrar.swift [\#198](https://github.com/skywinder/web3swift/pull/198) ([barrasso](https://github.com/barrasso)) +- Websockets improvements and fixes [\#189](https://github.com/skywinder/web3swift/pull/189) ([BaldyAsh](https://github.com/BaldyAsh)) +- Update ETHRegistrarController.swift [\#187](https://github.com/skywinder/web3swift/pull/187) ([barrasso](https://github.com/barrasso)) +- Update ETHRegistrarController.swift [\#183](https://github.com/skywinder/web3swift/pull/183) ([barrasso](https://github.com/barrasso)) +- Fix typo in Usage [\#182](https://github.com/skywinder/web3swift/pull/182) ([sweepty](https://github.com/sweepty)) +- Expose errorDescription. [\#181](https://github.com/skywinder/web3swift/pull/181) ([andresousa](https://github.com/andresousa)) +- Update ENS Resolver [\#180](https://github.com/skywinder/web3swift/pull/180) ([barrasso](https://github.com/barrasso)) -## [2.2.0](https://github.com/matter-labs/web3swift/tree/2.2.0) (2019-04-30) +## [2.2.0](https://github.com/skywinder/web3swift/tree/2.2.0) (2019-04-30) -[Full Changelog](https://github.com/matter-labs/web3swift/compare/2.1.6...2.2.0) +[Full Changelog](https://github.com/skywinder/web3swift/compare/2.1.6...2.2.0) **Closed issues:** -- Failed to fetch gas estimate [\#178](https://github.com/matter-labs/web3swift/issues/178) +- Failed to fetch gas estimate [\#178](https://github.com/skywinder/web3swift/issues/178) **Merged pull requests:** -- 2.2.0 [\#179](https://github.com/matter-labs/web3swift/pull/179) ([BaldyAsh](https://github.com/BaldyAsh)) +- 2.2.0 [\#179](https://github.com/skywinder/web3swift/pull/179) ([BaldyAsh](https://github.com/BaldyAsh)) -## [2.1.6](https://github.com/matter-labs/web3swift/tree/2.1.6) (2019-04-26) +## [2.1.6](https://github.com/skywinder/web3swift/tree/2.1.6) (2019-04-26) -[Full Changelog](https://github.com/matter-labs/web3swift/compare/2.1.5...2.1.6) +[Full Changelog](https://github.com/skywinder/web3swift/compare/2.1.5...2.1.6) **Merged pull requests:** -- 2.1.6 [\#175](https://github.com/matter-labs/web3swift/pull/175) ([BaldyAsh](https://github.com/BaldyAsh)) -- Quickfix ens [\#174](https://github.com/matter-labs/web3swift/pull/174) ([BaldyAsh](https://github.com/BaldyAsh)) +- 2.1.6 [\#175](https://github.com/skywinder/web3swift/pull/175) ([BaldyAsh](https://github.com/BaldyAsh)) +- Quickfix ens [\#174](https://github.com/skywinder/web3swift/pull/174) ([BaldyAsh](https://github.com/BaldyAsh)) -## [2.1.5](https://github.com/matter-labs/web3swift/tree/2.1.5) (2019-04-24) +## [2.1.5](https://github.com/skywinder/web3swift/tree/2.1.5) (2019-04-24) -[Full Changelog](https://github.com/matter-labs/web3swift/compare/2.1.4...2.1.5) +[Full Changelog](https://github.com/skywinder/web3swift/compare/2.1.4...2.1.5) **Merged pull requests:** -- Documentation update [\#153](https://github.com/matter-labs/web3swift/pull/153) ([BaldyAsh](https://github.com/BaldyAsh)) +- Documentation update [\#153](https://github.com/skywinder/web3swift/pull/153) ([BaldyAsh](https://github.com/BaldyAsh)) -## [2.1.4](https://github.com/matter-labs/web3swift/tree/2.1.4) (2019-04-24) +## [2.1.4](https://github.com/skywinder/web3swift/tree/2.1.4) (2019-04-24) -[Full Changelog](https://github.com/matter-labs/web3swift/compare/2.1.3...2.1.4) +[Full Changelog](https://github.com/skywinder/web3swift/compare/2.1.3...2.1.4) **Fixed bugs:** -- Cannot load module 'Web3swift' as 'web3swift [\#133](https://github.com/matter-labs/web3swift/issues/133) +- Cannot load module 'Web3swift' as 'web3swift [\#133](https://github.com/skywinder/web3swift/issues/133) **Closed issues:** -- How to convert 21000 BigUInt estimated gas price into Wei ? [\#163](https://github.com/matter-labs/web3swift/issues/163) -- ENS Permanent Registrar Support [\#159](https://github.com/matter-labs/web3swift/issues/159) -- web3swift 2.1.3 [\#154](https://github.com/matter-labs/web3swift/issues/154) -- Sending ETH always results in zero value [\#149](https://github.com/matter-labs/web3swift/issues/149) -- WebSockets subscriptions [\#145](https://github.com/matter-labs/web3swift/issues/145) -- 依赖该库生成framework,真机情况下会出现问题 [\#143](https://github.com/matter-labs/web3swift/issues/143) -- Building fails with compilation errors [\#140](https://github.com/matter-labs/web3swift/issues/140) +- How to convert 21000 BigUInt estimated gas price into Wei ? [\#163](https://github.com/skywinder/web3swift/issues/163) +- ENS Permanent Registrar Support [\#159](https://github.com/skywinder/web3swift/issues/159) +- web3swift 2.1.3 [\#154](https://github.com/skywinder/web3swift/issues/154) +- Sending ETH always results in zero value [\#149](https://github.com/skywinder/web3swift/issues/149) +- WebSockets subscriptions [\#145](https://github.com/skywinder/web3swift/issues/145) +- 依赖该库生成framework,真机情况下会出现问题 [\#143](https://github.com/skywinder/web3swift/issues/143) +- Building fails with compilation errors [\#140](https://github.com/skywinder/web3swift/issues/140) **Merged pull requests:** -- Fix travis [\#169](https://github.com/matter-labs/web3swift/pull/169) ([BaldyAsh](https://github.com/BaldyAsh)) -- Fix warnings [\#168](https://github.com/matter-labs/web3swift/pull/168) ([BaldyAsh](https://github.com/BaldyAsh)) -- Added reverse registrar [\#165](https://github.com/matter-labs/web3swift/pull/165) ([BaldyAsh](https://github.com/BaldyAsh)) -- WIP: ENS BaseRegistrar and RegistrarController support [\#162](https://github.com/matter-labs/web3swift/pull/162) ([BaldyAsh](https://github.com/BaldyAsh)) -- Updated example to 2.1.3 [\#158](https://github.com/matter-labs/web3swift/pull/158) ([BaldyAsh](https://github.com/BaldyAsh)) +- Fix travis [\#169](https://github.com/skywinder/web3swift/pull/169) ([BaldyAsh](https://github.com/BaldyAsh)) +- Fix warnings [\#168](https://github.com/skywinder/web3swift/pull/168) ([BaldyAsh](https://github.com/BaldyAsh)) +- Added reverse registrar [\#165](https://github.com/skywinder/web3swift/pull/165) ([BaldyAsh](https://github.com/BaldyAsh)) +- WIP: ENS BaseRegistrar and RegistrarController support [\#162](https://github.com/skywinder/web3swift/pull/162) ([BaldyAsh](https://github.com/BaldyAsh)) +- Updated example to 2.1.3 [\#158](https://github.com/skywinder/web3swift/pull/158) ([BaldyAsh](https://github.com/BaldyAsh)) -## [2.1.3](https://github.com/matter-labs/web3swift/tree/2.1.3) (2019-04-06) +## [2.1.3](https://github.com/skywinder/web3swift/tree/2.1.3) (2019-04-06) -[Full Changelog](https://github.com/matter-labs/web3swift/compare/2.1.2...2.1.3) +[Full Changelog](https://github.com/skywinder/web3swift/compare/2.1.2...2.1.3) **Implemented enhancements:** -- WIP: WebSockets subscriptions [\#144](https://github.com/matter-labs/web3swift/pull/144) ([BaldyAsh](https://github.com/BaldyAsh)) +- WIP: WebSockets subscriptions [\#144](https://github.com/skywinder/web3swift/pull/144) ([BaldyAsh](https://github.com/BaldyAsh)) **Closed issues:** -- Use custom JSONRPCmethod and Units [\#148](https://github.com/matter-labs/web3swift/issues/148) -- ERC20 some functions are not working [\#146](https://github.com/matter-labs/web3swift/issues/146) -- fix `pod install` absolute paths [\#97](https://github.com/matter-labs/web3swift/issues/97) -- Installing issue by pod [\#76](https://github.com/matter-labs/web3swift/issues/76) +- Use custom JSONRPCmethod and Units [\#148](https://github.com/skywinder/web3swift/issues/148) +- ERC20 some functions are not working [\#146](https://github.com/skywinder/web3swift/issues/146) +- fix `pod install` absolute paths [\#97](https://github.com/skywinder/web3swift/issues/97) +- Installing issue by pod [\#76](https://github.com/skywinder/web3swift/issues/76) **Merged pull requests:** -- 2.1.3 fix No2 [\#152](https://github.com/matter-labs/web3swift/pull/152) ([BaldyAsh](https://github.com/BaldyAsh)) -- 2.1.3 fix [\#151](https://github.com/matter-labs/web3swift/pull/151) ([BaldyAsh](https://github.com/BaldyAsh)) -- 2.1.3 [\#150](https://github.com/matter-labs/web3swift/pull/150) ([BaldyAsh](https://github.com/BaldyAsh)) +- 2.1.3 fix No2 [\#152](https://github.com/skywinder/web3swift/pull/152) ([BaldyAsh](https://github.com/BaldyAsh)) +- 2.1.3 fix [\#151](https://github.com/skywinder/web3swift/pull/151) ([BaldyAsh](https://github.com/BaldyAsh)) +- 2.1.3 [\#150](https://github.com/skywinder/web3swift/pull/150) ([BaldyAsh](https://github.com/BaldyAsh)) -## [2.1.2](https://github.com/matter-labs/web3swift/tree/2.1.2) (2019-03-30) +## [2.1.2](https://github.com/skywinder/web3swift/tree/2.1.2) (2019-03-30) -[Full Changelog](https://github.com/matter-labs/web3swift/compare/2.1.1...2.1.2) +[Full Changelog](https://github.com/skywinder/web3swift/compare/2.1.1...2.1.2) **Merged pull requests:** -- Swift 5 update [\#141](https://github.com/matter-labs/web3swift/pull/141) ([BaldyAsh](https://github.com/BaldyAsh)) -- Swift 5 update [\#139](https://github.com/matter-labs/web3swift/pull/139) ([BaldyAsh](https://github.com/BaldyAsh)) -- 2.1.1 [\#136](https://github.com/matter-labs/web3swift/pull/136) ([BaldyAsh](https://github.com/BaldyAsh)) +- Swift 5 update [\#141](https://github.com/skywinder/web3swift/pull/141) ([BaldyAsh](https://github.com/BaldyAsh)) +- Swift 5 update [\#139](https://github.com/skywinder/web3swift/pull/139) ([BaldyAsh](https://github.com/BaldyAsh)) +- 2.1.1 [\#136](https://github.com/skywinder/web3swift/pull/136) ([BaldyAsh](https://github.com/BaldyAsh)) -## [2.1.1](https://github.com/matter-labs/web3swift/tree/2.1.1) (2019-03-26) +## [2.1.1](https://github.com/skywinder/web3swift/tree/2.1.1) (2019-03-26) -[Full Changelog](https://github.com/matter-labs/web3swift/compare/2.1.0...2.1.1) +[Full Changelog](https://github.com/skywinder/web3swift/compare/2.1.0...2.1.1) **Implemented enhancements:** -- Support ST-20 [\#103](https://github.com/matter-labs/web3swift/issues/103) +- Support ST-20 [\#103](https://github.com/skywinder/web3swift/issues/103) **Closed issues:** -- Expected to decode Array\ but found a dictionary instead. [\#128](https://github.com/matter-labs/web3swift/issues/128) -- Decoding Input/Output data [\#127](https://github.com/matter-labs/web3swift/issues/127) -- nodeError\("replacement transaction underpriced"\) [\#42](https://github.com/matter-labs/web3swift/issues/42) +- Expected to decode Array\ but found a dictionary instead. [\#128](https://github.com/skywinder/web3swift/issues/128) +- Decoding Input/Output data [\#127](https://github.com/skywinder/web3swift/issues/127) +- nodeError\("replacement transaction underpriced"\) [\#42](https://github.com/skywinder/web3swift/issues/42) **Merged pull requests:** -- Fix/podspec [\#135](https://github.com/matter-labs/web3swift/pull/135) ([BaldyAsh](https://github.com/BaldyAsh)) -- let some functions public for customization [\#132](https://github.com/matter-labs/web3swift/pull/132) ([scottphc](https://github.com/scottphc)) -- WIP: ST-20 and Security Token support [\#130](https://github.com/matter-labs/web3swift/pull/130) ([BaldyAsh](https://github.com/BaldyAsh)) -- Fix/remove deprecated [\#120](https://github.com/matter-labs/web3swift/pull/120) ([BaldyAsh](https://github.com/BaldyAsh)) +- Fix/podspec [\#135](https://github.com/skywinder/web3swift/pull/135) ([BaldyAsh](https://github.com/BaldyAsh)) +- let some functions public for customization [\#132](https://github.com/skywinder/web3swift/pull/132) ([scottphc](https://github.com/scottphc)) +- WIP: ST-20 and Security Token support [\#130](https://github.com/skywinder/web3swift/pull/130) ([BaldyAsh](https://github.com/BaldyAsh)) +- Fix/remove deprecated [\#120](https://github.com/skywinder/web3swift/pull/120) ([BaldyAsh](https://github.com/BaldyAsh)) -## [2.1.0](https://github.com/matter-labs/web3swift/tree/2.1.0) (2019-03-06) +## [2.1.0](https://github.com/skywinder/web3swift/tree/2.1.0) (2019-03-06) -[Full Changelog](https://github.com/matter-labs/web3swift/compare/2.0.4...2.1.0) +[Full Changelog](https://github.com/skywinder/web3swift/compare/2.0.4...2.1.0) **Implemented enhancements:** -- Support ERC-888 [\#102](https://github.com/matter-labs/web3swift/issues/102) -- Support SRC-20 [\#101](https://github.com/matter-labs/web3swift/issues/101) -- Support S3 [\#99](https://github.com/matter-labs/web3swift/issues/99) -- Support ERC-1400 [\#98](https://github.com/matter-labs/web3swift/issues/98) -- ERC-165 support [\#82](https://github.com/matter-labs/web3swift/issues/82) -- ERC-777 support [\#81](https://github.com/matter-labs/web3swift/issues/81) -- How do I add an account to a node [\#78](https://github.com/matter-labs/web3swift/issues/78) -- Support Web3View functionality [\#30](https://github.com/matter-labs/web3swift/issues/30) +- Support ERC-888 [\#102](https://github.com/skywinder/web3swift/issues/102) +- Support SRC-20 [\#101](https://github.com/skywinder/web3swift/issues/101) +- Support S3 [\#99](https://github.com/skywinder/web3swift/issues/99) +- Support ERC-1400 [\#98](https://github.com/skywinder/web3swift/issues/98) +- ERC-165 support [\#82](https://github.com/skywinder/web3swift/issues/82) +- ERC-777 support [\#81](https://github.com/skywinder/web3swift/issues/81) +- How do I add an account to a node [\#78](https://github.com/skywinder/web3swift/issues/78) +- ERC20 API Support [\#41](https://github.com/skywinder/web3swift/issues/41) +- Support Web3View functionality [\#30](https://github.com/skywinder/web3swift/issues/30) **Closed issues:** -- eth\_estimateGas is not supplied the gasPrice parameter [\#118](https://github.com/matter-labs/web3swift/issues/118) -- Carthage support missing. [\#115](https://github.com/matter-labs/web3swift/issues/115) -- \[Utility\] Contract event listener [\#112](https://github.com/matter-labs/web3swift/issues/112) -- Support ERC-1644 [\#111](https://github.com/matter-labs/web3swift/issues/111) -- Support ERC-1643 [\#110](https://github.com/matter-labs/web3swift/issues/110) -- Support ERC-1594 [\#109](https://github.com/matter-labs/web3swift/issues/109) -- Support ERC-1410 [\#108](https://github.com/matter-labs/web3swift/issues/108) -- Support ERC-820 [\#107](https://github.com/matter-labs/web3swift/issues/107) -- Error: Failed to fetch gas estimate on intermediate call [\#106](https://github.com/matter-labs/web3swift/issues/106) -- Can't use ENS in 2.0 [\#92](https://github.com/matter-labs/web3swift/issues/92) -- Can't use EIP681 parser [\#91](https://github.com/matter-labs/web3swift/issues/91) -- enhancement - end to end newbie instructions to deploy erc20 token locally / initialize wallets - then successfully transfer it in app [\#89](https://github.com/matter-labs/web3swift/issues/89) -- Can you support objective-c [\#88](https://github.com/matter-labs/web3swift/issues/88) -- SolidityType has no member 'allSatisfy'? [\#87](https://github.com/matter-labs/web3swift/issues/87) -- How to encode data for appending constructor to bytecode for deploying contract? [\#86](https://github.com/matter-labs/web3swift/issues/86) -- web3swift.Web3Error error 4 for get balance [\#77](https://github.com/matter-labs/web3swift/issues/77) -- How to signed Transaction ? get raw [\#62](https://github.com/matter-labs/web3swift/issues/62) -- how to get token using Signing Transaction [\#58](https://github.com/matter-labs/web3swift/issues/58) -- Can the signtypedMessage function be added [\#45](https://github.com/matter-labs/web3swift/issues/45) -- How to get Keystore by PrivateKeyData ? [\#19](https://github.com/matter-labs/web3swift/issues/19) -- encoding name\(ens\) for sending register contract [\#15](https://github.com/matter-labs/web3swift/issues/15) +- eth\_estimateGas is not supplied the gasPrice parameter [\#118](https://github.com/skywinder/web3swift/issues/118) +- Carthage support missing. [\#115](https://github.com/skywinder/web3swift/issues/115) +- \[Utility\] Contract event listener [\#112](https://github.com/skywinder/web3swift/issues/112) +- Support ERC-1644 [\#111](https://github.com/skywinder/web3swift/issues/111) +- Support ERC-1643 [\#110](https://github.com/skywinder/web3swift/issues/110) +- Support ERC-1594 [\#109](https://github.com/skywinder/web3swift/issues/109) +- Support ERC-1410 [\#108](https://github.com/skywinder/web3swift/issues/108) +- Support ERC-820 [\#107](https://github.com/skywinder/web3swift/issues/107) +- Error: Failed to fetch gas estimate on intermediate call [\#106](https://github.com/skywinder/web3swift/issues/106) +- Can't use ENS in 2.0 [\#92](https://github.com/skywinder/web3swift/issues/92) +- Can't use EIP681 parser [\#91](https://github.com/skywinder/web3swift/issues/91) +- enhancement - end to end newbie instructions to deploy erc20 token locally / initialize wallets - then successfully transfer it in app [\#89](https://github.com/skywinder/web3swift/issues/89) +- Can you support objective-c [\#88](https://github.com/skywinder/web3swift/issues/88) +- SolidityType has no member 'allSatisfy'? [\#87](https://github.com/skywinder/web3swift/issues/87) +- How to encode data for appending constructor to bytecode for deploying contract? [\#86](https://github.com/skywinder/web3swift/issues/86) +- web3swift.Web3Error error 4 for get balance [\#77](https://github.com/skywinder/web3swift/issues/77) +- How to signed Transaction ? get raw [\#62](https://github.com/skywinder/web3swift/issues/62) +- how to get token using Signing Transaction [\#58](https://github.com/skywinder/web3swift/issues/58) +- Can the signtypedMessage function be added [\#45](https://github.com/skywinder/web3swift/issues/45) +- Migration to web3 format \(create account\) [\#40](https://github.com/skywinder/web3swift/issues/40) +- How to get Keystore by PrivateKeyData ? [\#19](https://github.com/skywinder/web3swift/issues/19) +- encoding name\(ens\) for sending register contract [\#15](https://github.com/skywinder/web3swift/issues/15) **Merged pull requests:** -- 2.1.0 [\#124](https://github.com/matter-labs/web3swift/pull/124) ([BaldyAsh](https://github.com/BaldyAsh)) -- Fix/remove deprecated [\#123](https://github.com/matter-labs/web3swift/pull/123) ([BaldyAsh](https://github.com/BaldyAsh)) -- fixed estimate gas problem [\#119](https://github.com/matter-labs/web3swift/pull/119) ([BaldyAsh](https://github.com/BaldyAsh)) -- Added Deed and Registrar ABI to Web3+Utils [\#114](https://github.com/matter-labs/web3swift/pull/114) ([barrasso](https://github.com/barrasso)) -- Fixed EIP681 and EIP67, added and improved a lot of ERCs [\#113](https://github.com/matter-labs/web3swift/pull/113) ([BaldyAsh](https://github.com/BaldyAsh)) -- Documentation [\#105](https://github.com/matter-labs/web3swift/pull/105) ([BaldyAsh](https://github.com/BaldyAsh)) -- recent changes [\#104](https://github.com/matter-labs/web3swift/pull/104) ([BaldyAsh](https://github.com/BaldyAsh)) -- Migration to 2.0 [\#96](https://github.com/matter-labs/web3swift/pull/96) ([BaldyAsh](https://github.com/BaldyAsh)) -- Master to develop for 2.0.2 [\#94](https://github.com/matter-labs/web3swift/pull/94) ([shamatar](https://github.com/shamatar)) -- Feature/readme improvement [\#85](https://github.com/matter-labs/web3swift/pull/85) ([BaldyAsh](https://github.com/BaldyAsh)) -- Get recent develop changes [\#80](https://github.com/matter-labs/web3swift/pull/80) ([BaldyAsh](https://github.com/BaldyAsh)) - -## [2.0.4](https://github.com/matter-labs/web3swift/tree/2.0.4) (2018-11-20) +- 2.1.0 [\#124](https://github.com/skywinder/web3swift/pull/124) ([BaldyAsh](https://github.com/BaldyAsh)) +- Fix/remove deprecated [\#123](https://github.com/skywinder/web3swift/pull/123) ([BaldyAsh](https://github.com/BaldyAsh)) +- fixed estimate gas problem [\#119](https://github.com/skywinder/web3swift/pull/119) ([BaldyAsh](https://github.com/BaldyAsh)) +- Added Deed and Registrar ABI to Web3+Utils [\#114](https://github.com/skywinder/web3swift/pull/114) ([barrasso](https://github.com/barrasso)) +- Fixed EIP681 and EIP67, added and improved a lot of ERCs [\#113](https://github.com/skywinder/web3swift/pull/113) ([BaldyAsh](https://github.com/BaldyAsh)) +- Documentation [\#105](https://github.com/skywinder/web3swift/pull/105) ([BaldyAsh](https://github.com/BaldyAsh)) +- recent changes [\#104](https://github.com/skywinder/web3swift/pull/104) ([BaldyAsh](https://github.com/BaldyAsh)) +- Migration to 2.0 [\#96](https://github.com/skywinder/web3swift/pull/96) ([BaldyAsh](https://github.com/BaldyAsh)) +- Master to develop for 2.0.2 [\#94](https://github.com/skywinder/web3swift/pull/94) ([shamatar](https://github.com/shamatar)) +- 2.0.2 [\#93](https://github.com/skywinder/web3swift/pull/93) ([shamatar](https://github.com/shamatar)) +- Feature/readme improvement [\#85](https://github.com/skywinder/web3swift/pull/85) ([BaldyAsh](https://github.com/BaldyAsh)) +- Get recent develop changes [\#80](https://github.com/skywinder/web3swift/pull/80) ([BaldyAsh](https://github.com/BaldyAsh)) -[Full Changelog](https://github.com/matter-labs/web3swift/compare/2.0.3...2.0.4) - -**Merged pull requests:** +## [2.0.4](https://github.com/skywinder/web3swift/tree/2.0.4) (2018-11-20) -- introduce a fix for invalid value in gas estimation, call and send transactions [\#95](https://github.com/matter-labs/web3swift/pull/95) ([shamatar](https://github.com/shamatar)) -- 2.0.2 [\#93](https://github.com/matter-labs/web3swift/pull/93) ([shamatar](https://github.com/shamatar)) +[Full Changelog](https://github.com/skywinder/web3swift/compare/2.0.3...2.0.4) -## [2.0.3](https://github.com/matter-labs/web3swift/tree/2.0.3) (2018-11-20) +## [2.0.3](https://github.com/skywinder/web3swift/tree/2.0.3) (2018-11-20) -[Full Changelog](https://github.com/matter-labs/web3swift/compare/2.0.2...2.0.3) +[Full Changelog](https://github.com/skywinder/web3swift/compare/2.0.2...2.0.3) -## [2.0.2](https://github.com/matter-labs/web3swift/tree/2.0.2) (2018-11-06) +## [2.0.2](https://github.com/skywinder/web3swift/tree/2.0.2) (2018-11-06) -[Full Changelog](https://github.com/matter-labs/web3swift/compare/2.0.1...2.0.2) +[Full Changelog](https://github.com/skywinder/web3swift/compare/2.0.1...2.0.2) **Merged pull requests:** -- 2.0.1 [\#84](https://github.com/matter-labs/web3swift/pull/84) ([shamatar](https://github.com/shamatar)) +- 2.0.1 [\#84](https://github.com/skywinder/web3swift/pull/84) ([shamatar](https://github.com/shamatar)) -## [2.0.1](https://github.com/matter-labs/web3swift/tree/2.0.1) (2018-11-05) +## [2.0.1](https://github.com/skywinder/web3swift/tree/2.0.1) (2018-11-05) -[Full Changelog](https://github.com/matter-labs/web3swift/compare/2.0.0...2.0.1) +[Full Changelog](https://github.com/skywinder/web3swift/compare/2.0.0...2.0.1) **Closed issues:** -- ENS Functionality [\#56](https://github.com/matter-labs/web3swift/issues/56) +- ENS Functionality [\#56](https://github.com/skywinder/web3swift/issues/56) **Merged pull requests:** -- ENS fix [\#83](https://github.com/matter-labs/web3swift/pull/83) ([BaldyAsh](https://github.com/BaldyAsh)) +- ENS fix [\#83](https://github.com/skywinder/web3swift/pull/83) ([BaldyAsh](https://github.com/BaldyAsh)) -## [2.0.0](https://github.com/matter-labs/web3swift/tree/2.0.0) (2018-10-30) +## [2.0.0](https://github.com/skywinder/web3swift/tree/2.0.0) (2018-10-30) -[Full Changelog](https://github.com/matter-labs/web3swift/compare/1.5.1...2.0.0) +[Full Changelog](https://github.com/skywinder/web3swift/compare/1.5.1...2.0.0) **Implemented enhancements:** -- Carthage support [\#44](https://github.com/matter-labs/web3swift/issues/44) -- How to get pending transactions by this framework [\#36](https://github.com/matter-labs/web3swift/issues/36) -- ENS for wallets [\#12](https://github.com/matter-labs/web3swift/issues/12) -- Recover passphrase from BIP32 store [\#5](https://github.com/matter-labs/web3swift/issues/5) -- ERC20 API Support [\#41](https://github.com/matter-labs/web3swift/issues/41) +- Carthage support [\#44](https://github.com/skywinder/web3swift/issues/44) +- How to get pending transactions by this framework [\#36](https://github.com/skywinder/web3swift/issues/36) +- ENS for wallets [\#12](https://github.com/skywinder/web3swift/issues/12) +- Recover passphrase from BIP32 store [\#5](https://github.com/skywinder/web3swift/issues/5) +- ERC20 API Support [\#41](https://github.com/skywinder/web3swift/issues/41) **Closed issues:** -- failed to send transaction due to known transaction [\#65](https://github.com/matter-labs/web3swift/issues/65) -- List of all transactions related to account \(private key\) [\#57](https://github.com/matter-labs/web3swift/issues/57) -- Make A README & doc [\#46](https://github.com/matter-labs/web3swift/issues/46) -- 'BigUInt' is ambiguous for type lookup in this conte [\#43](https://github.com/matter-labs/web3swift/issues/43) -- Migration to web3 format \(create account\) [\#40](https://github.com/matter-labs/web3swift/issues/40) -- Interface ideas are welcome for v2.0 [\#3](https://github.com/matter-labs/web3swift/issues/3) +- failed to send transaction due to known transaction [\#65](https://github.com/skywinder/web3swift/issues/65) +- List of all transactions related to account \(private key\) [\#57](https://github.com/skywinder/web3swift/issues/57) +- Make A README & doc [\#46](https://github.com/skywinder/web3swift/issues/46) +- 'BigUInt' is ambiguous for type lookup in this conte [\#43](https://github.com/skywinder/web3swift/issues/43) +- Migration to web3 format \(create account\) [\#40](https://github.com/skywinder/web3swift/issues/40) +- Interface ideas are welcome for v2.0 [\#3](https://github.com/skywinder/web3swift/issues/3) **Merged pull requests:** -- Carthage [\#75](https://github.com/matter-labs/web3swift/pull/75) ([BaldyAsh](https://github.com/BaldyAsh)) -- Carthage fixes [\#74](https://github.com/matter-labs/web3swift/pull/74) ([BaldyAsh](https://github.com/BaldyAsh)) +- Carthage [\#75](https://github.com/skywinder/web3swift/pull/75) ([BaldyAsh](https://github.com/BaldyAsh)) +- Carthage fixes [\#74](https://github.com/skywinder/web3swift/pull/74) ([BaldyAsh](https://github.com/BaldyAsh)) -## [1.5.1](https://github.com/matter-labs/web3swift/tree/1.5.1) (2018-10-22) +## [1.5.1](https://github.com/skywinder/web3swift/tree/1.5.1) (2018-10-22) -[Full Changelog](https://github.com/matter-labs/web3swift/compare/1.5...1.5.1) +[Full Changelog](https://github.com/skywinder/web3swift/compare/1.5...1.5.1) **Merged pull requests:** -- Function visibility fix [\#70](https://github.com/matter-labs/web3swift/pull/70) ([shamatar](https://github.com/shamatar)) +- Function visibility fix [\#70](https://github.com/skywinder/web3swift/pull/70) ([shamatar](https://github.com/shamatar)) -## [1.5](https://github.com/matter-labs/web3swift/tree/1.5) (2018-10-18) +## [1.5](https://github.com/skywinder/web3swift/tree/1.5) (2018-10-18) -[Full Changelog](https://github.com/matter-labs/web3swift/compare/1.1.10...1.5) +[Full Changelog](https://github.com/skywinder/web3swift/compare/1.1.10...1.5) **Implemented enhancements:** -- Can you add support for ERC-721 tokens [\#7](https://github.com/matter-labs/web3swift/issues/7) +- Can you add support for ERC-721 tokens [\#7](https://github.com/skywinder/web3swift/issues/7) **Closed issues:** -- Creating a new wallet is too slow [\#63](https://github.com/matter-labs/web3swift/issues/63) -- need to update for Xcode10 [\#49](https://github.com/matter-labs/web3swift/issues/49) -- Web3.Utils.formatToEthereumUnits [\#48](https://github.com/matter-labs/web3swift/issues/48) +- Creating a new wallet is too slow [\#63](https://github.com/skywinder/web3swift/issues/63) +- need to update for Xcode10 [\#49](https://github.com/skywinder/web3swift/issues/49) +- Web3.Utils.formatToEthereumUnits [\#48](https://github.com/skywinder/web3swift/issues/48) +- Interface ideas are welcome for v2.0 [\#3](https://github.com/skywinder/web3swift/issues/3) **Merged pull requests:** -- Add TxPool and ERC721 native class [\#68](https://github.com/matter-labs/web3swift/pull/68) ([shamatar](https://github.com/shamatar)) -- Feature/erc721 [\#67](https://github.com/matter-labs/web3swift/pull/67) ([BaldyAsh](https://github.com/BaldyAsh)) -- Feature/adding logo [\#66](https://github.com/matter-labs/web3swift/pull/66) ([BaldyAsh](https://github.com/BaldyAsh)) -- adds txpool function and its local node test [\#64](https://github.com/matter-labs/web3swift/pull/64) ([currybab](https://github.com/currybab)) -- License got reverted somewhere after PRs [\#60](https://github.com/matter-labs/web3swift/pull/60) ([shamatar](https://github.com/shamatar)) +- Add TxPool and ERC721 native class [\#68](https://github.com/skywinder/web3swift/pull/68) ([shamatar](https://github.com/shamatar)) +- Feature/erc721 [\#67](https://github.com/skywinder/web3swift/pull/67) ([BaldyAsh](https://github.com/BaldyAsh)) +- Feature/adding logo [\#66](https://github.com/skywinder/web3swift/pull/66) ([BaldyAsh](https://github.com/BaldyAsh)) +- adds txpool function and its local node test [\#64](https://github.com/skywinder/web3swift/pull/64) ([currybab](https://github.com/currybab)) +- License got reverted somewhere after PRs [\#60](https://github.com/skywinder/web3swift/pull/60) ([shamatar](https://github.com/shamatar)) -## [1.1.10](https://github.com/matter-labs/web3swift/tree/1.1.10) (2018-10-04) +## [1.1.10](https://github.com/skywinder/web3swift/tree/1.1.10) (2018-10-04) -[Full Changelog](https://github.com/matter-labs/web3swift/compare/1.1.9...1.1.10) +[Full Changelog](https://github.com/skywinder/web3swift/compare/1.1.9...1.1.10) **Merged pull requests:** -- Preliminary ENS support, start module splitting [\#59](https://github.com/matter-labs/web3swift/pull/59) ([shamatar](https://github.com/shamatar)) -- Feature/readme improvement [\#55](https://github.com/matter-labs/web3swift/pull/55) ([BaldyAsh](https://github.com/BaldyAsh)) -- Feature/support obj c [\#54](https://github.com/matter-labs/web3swift/pull/54) ([BaldyAsh](https://github.com/BaldyAsh)) -- Feature/ENSsupport [\#53](https://github.com/matter-labs/web3swift/pull/53) ([FesenkoG](https://github.com/FesenkoG)) -- Add Travis configuration [\#52](https://github.com/matter-labs/web3swift/pull/52) ([skywinder](https://github.com/skywinder)) -- Added ERC-20 token for testing web3swift lib [\#50](https://github.com/matter-labs/web3swift/pull/50) ([BaldyAsh](https://github.com/BaldyAsh)) +- Preliminary ENS support, start module splitting [\#59](https://github.com/skywinder/web3swift/pull/59) ([shamatar](https://github.com/shamatar)) +- Feature/readme improvement [\#55](https://github.com/skywinder/web3swift/pull/55) ([BaldyAsh](https://github.com/BaldyAsh)) +- Feature/support obj c [\#54](https://github.com/skywinder/web3swift/pull/54) ([BaldyAsh](https://github.com/BaldyAsh)) +- Feature/ENSsupport [\#53](https://github.com/skywinder/web3swift/pull/53) ([FesenkoG](https://github.com/FesenkoG)) +- Add Travis configuration [\#52](https://github.com/skywinder/web3swift/pull/52) ([skywinder](https://github.com/skywinder)) +- Added ERC-20 token for testing web3swift lib [\#50](https://github.com/skywinder/web3swift/pull/50) ([BaldyAsh](https://github.com/BaldyAsh)) -## [1.1.9](https://github.com/matter-labs/web3swift/tree/1.1.9) (2018-09-18) +## [1.1.9](https://github.com/skywinder/web3swift/tree/1.1.9) (2018-09-18) -[Full Changelog](https://github.com/matter-labs/web3swift/compare/1.1.7...1.1.9) +[Full Changelog](https://github.com/skywinder/web3swift/compare/1.1.7...1.1.9) **Fixed bugs:** -- eth.getAccounts\(\) function returns an empty address Array [\#24](https://github.com/matter-labs/web3swift/issues/24) -- EIP681 bug fixes, accessibility in Function changed [\#35](https://github.com/matter-labs/web3swift/pull/35) ([FesenkoG](https://github.com/FesenkoG)) +- eth.getAccounts\(\) function returns an empty address Array [\#24](https://github.com/skywinder/web3swift/issues/24) +- EIP681 bug fixes, accessibility in Function changed [\#35](https://github.com/skywinder/web3swift/pull/35) ([FesenkoG](https://github.com/FesenkoG)) **Closed issues:** -- the version 1.1.6 couldn't from password and keystore to get the privateKey [\#32](https://github.com/matter-labs/web3swift/issues/32) -- Need implementation of EIP-681 parsing [\#25](https://github.com/matter-labs/web3swift/issues/25) +- the version 1.1.6 couldn't from password and keystore to get the privateKey [\#32](https://github.com/skywinder/web3swift/issues/32) +- Need implementation of EIP-681 parsing [\#25](https://github.com/skywinder/web3swift/issues/25) **Merged pull requests:** -- Update for XCode 10 [\#39](https://github.com/matter-labs/web3swift/pull/39) ([shamatar](https://github.com/shamatar)) -- Basic ENS support added, EIP681 parsing supports ENS from now. [\#38](https://github.com/matter-labs/web3swift/pull/38) ([FesenkoG](https://github.com/FesenkoG)) +- Update for XCode 10 [\#39](https://github.com/skywinder/web3swift/pull/39) ([shamatar](https://github.com/shamatar)) +- Basic ENS support added, EIP681 parsing supports ENS from now. [\#38](https://github.com/skywinder/web3swift/pull/38) ([FesenkoG](https://github.com/FesenkoG)) -## [1.1.7](https://github.com/matter-labs/web3swift/tree/1.1.7) (2018-09-13) +## [1.1.7](https://github.com/skywinder/web3swift/tree/1.1.7) (2018-09-13) -[Full Changelog](https://github.com/matter-labs/web3swift/compare/1.1.6...1.1.7) +[Full Changelog](https://github.com/skywinder/web3swift/compare/1.1.6...1.1.7) **Fixed bugs:** -- Thread blocked [\#16](https://github.com/matter-labs/web3swift/issues/16) +- Thread blocked [\#16](https://github.com/skywinder/web3swift/issues/16) **Closed issues:** -- How to create same address and keystore by mnemonics? [\#22](https://github.com/matter-labs/web3swift/issues/22) +- How to create same address and keystore by mnemonics? [\#22](https://github.com/skywinder/web3swift/issues/22) **Merged pull requests:** -- Fix ethereum address parsing, add readme [\#34](https://github.com/matter-labs/web3swift/pull/34) ([shamatar](https://github.com/shamatar)) -- complete EIP681, fix the most stupid Ethereum address parsing [\#33](https://github.com/matter-labs/web3swift/pull/33) ([shamatar](https://github.com/shamatar)) -- Add examples to readme, prettify formatting [\#31](https://github.com/matter-labs/web3swift/pull/31) ([skywinder](https://github.com/skywinder)) -- continue eip681 work [\#27](https://github.com/matter-labs/web3swift/pull/27) ([shamatar](https://github.com/shamatar)) -- Implement EIP681 parser \(untested\) [\#26](https://github.com/matter-labs/web3swift/pull/26) ([shamatar](https://github.com/shamatar)) -- Change access control of function fromRaw in struct EthereumTransaction [\#11](https://github.com/matter-labs/web3swift/pull/11) ([Plazmathron](https://github.com/Plazmathron)) +- Fix ethereum address parsing, add readme [\#34](https://github.com/skywinder/web3swift/pull/34) ([shamatar](https://github.com/shamatar)) +- complete EIP681, fix the most stupid Ethereum address parsing [\#33](https://github.com/skywinder/web3swift/pull/33) ([shamatar](https://github.com/shamatar)) +- Add examples to readme, prettify formatting [\#31](https://github.com/skywinder/web3swift/pull/31) ([skywinder](https://github.com/skywinder)) +- continue eip681 work [\#27](https://github.com/skywinder/web3swift/pull/27) ([shamatar](https://github.com/shamatar)) +- Implement EIP681 parser \(untested\) [\#26](https://github.com/skywinder/web3swift/pull/26) ([shamatar](https://github.com/shamatar)) +- Change access control of function fromRaw in struct EthereumTransaction [\#11](https://github.com/skywinder/web3swift/pull/11) ([Plazmathron](https://github.com/Plazmathron)) -## [1.1.6](https://github.com/matter-labs/web3swift/tree/1.1.6) (2018-09-04) +## [1.1.6](https://github.com/skywinder/web3swift/tree/1.1.6) (2018-09-04) -[Full Changelog](https://github.com/matter-labs/web3swift/compare/1.1.5...1.1.6) +[Full Changelog](https://github.com/skywinder/web3swift/compare/1.1.5...1.1.6) **Merged pull requests:** -- Quick fix for scrypt performance [\#17](https://github.com/matter-labs/web3swift/pull/17) ([shamatar](https://github.com/shamatar)) -- adding description string to Web3Error [\#1](https://github.com/matter-labs/web3swift/pull/1) ([GabCas](https://github.com/GabCas)) +- Quick fix for scrypt performance [\#17](https://github.com/skywinder/web3swift/pull/17) ([shamatar](https://github.com/shamatar)) +- adding description string to Web3Error [\#1](https://github.com/skywinder/web3swift/pull/1) ([GabCas](https://github.com/GabCas)) + +## [1.1.5](https://github.com/skywinder/web3swift/tree/1.1.5) (2018-08-10) + +[Full Changelog](https://github.com/skywinder/web3swift/compare/1.1.1...1.1.5) + +## [1.1.1](https://github.com/skywinder/web3swift/tree/1.1.1) (2018-07-30) + +[Full Changelog](https://github.com/skywinder/web3swift/compare/1.1.0...1.1.1) + +## [1.1.0](https://github.com/skywinder/web3swift/tree/1.1.0) (2018-07-27) + +[Full Changelog](https://github.com/skywinder/web3swift/compare/1.0.1...1.1.0) + +## [1.0.1](https://github.com/skywinder/web3swift/tree/1.0.1) (2018-07-12) + +[Full Changelog](https://github.com/skywinder/web3swift/compare/1.0.0...1.0.1) + +## [1.0.0](https://github.com/skywinder/web3swift/tree/1.0.0) (2018-07-04) + +[Full Changelog](https://github.com/skywinder/web3swift/compare/0.9.0...1.0.0) + +## [0.9.0](https://github.com/skywinder/web3swift/tree/0.9.0) (2018-06-18) + +[Full Changelog](https://github.com/skywinder/web3swift/compare/0.8.1...0.9.0) + +## [0.8.1](https://github.com/skywinder/web3swift/tree/0.8.1) (2018-06-10) + +[Full Changelog](https://github.com/skywinder/web3swift/compare/0.8.0...0.8.1) + +## [0.8.0](https://github.com/skywinder/web3swift/tree/0.8.0) (2018-05-31) + +[Full Changelog](https://github.com/skywinder/web3swift/compare/0.7.9...0.8.0) + +## [0.7.9](https://github.com/skywinder/web3swift/tree/0.7.9) (2018-05-31) + +[Full Changelog](https://github.com/skywinder/web3swift/compare/0.7.0...0.7.9) + +## [0.7.0](https://github.com/skywinder/web3swift/tree/0.7.0) (2018-05-11) + +[Full Changelog](https://github.com/skywinder/web3swift/compare/0.6.0...0.7.0) + +## [0.6.0](https://github.com/skywinder/web3swift/tree/0.6.0) (2018-04-24) + +[Full Changelog](https://github.com/skywinder/web3swift/compare/0.5.6...0.6.0) + +## [0.5.6](https://github.com/skywinder/web3swift/tree/0.5.6) (2018-04-20) + +[Full Changelog](https://github.com/skywinder/web3swift/compare/0.5.5...0.5.6) + +## [0.5.5](https://github.com/skywinder/web3swift/tree/0.5.5) (2018-04-18) + +[Full Changelog](https://github.com/skywinder/web3swift/compare/0.5.4...0.5.5) + +## [0.5.4](https://github.com/skywinder/web3swift/tree/0.5.4) (2018-04-16) + +[Full Changelog](https://github.com/skywinder/web3swift/compare/0.5.3...0.5.4) + +## [0.5.3](https://github.com/skywinder/web3swift/tree/0.5.3) (2018-04-16) + +[Full Changelog](https://github.com/skywinder/web3swift/compare/0.5.2...0.5.3) + +## [0.5.2](https://github.com/skywinder/web3swift/tree/0.5.2) (2018-04-16) + +[Full Changelog](https://github.com/skywinder/web3swift/compare/0.5.1...0.5.2) + +## [0.5.1](https://github.com/skywinder/web3swift/tree/0.5.1) (2018-04-11) + +[Full Changelog](https://github.com/skywinder/web3swift/compare/0.5.0...0.5.1) + +## [0.5.0](https://github.com/skywinder/web3swift/tree/0.5.0) (2018-04-10) + +[Full Changelog](https://github.com/skywinder/web3swift/compare/0.4.1...0.5.0) + +## [0.4.1](https://github.com/skywinder/web3swift/tree/0.4.1) (2018-04-07) + +[Full Changelog](https://github.com/skywinder/web3swift/compare/0.4.0...0.4.1) + +## [0.4.0](https://github.com/skywinder/web3swift/tree/0.4.0) (2018-04-04) + +[Full Changelog](https://github.com/skywinder/web3swift/compare/0.3.6...0.4.0) + +## [0.3.6](https://github.com/skywinder/web3swift/tree/0.3.6) (2018-04-02) + +[Full Changelog](https://github.com/skywinder/web3swift/compare/0.3.5...0.3.6) + +## [0.3.5](https://github.com/skywinder/web3swift/tree/0.3.5) (2018-03-20) + +[Full Changelog](https://github.com/skywinder/web3swift/compare/0.3.4...0.3.5) + +## [0.3.4](https://github.com/skywinder/web3swift/tree/0.3.4) (2018-03-18) + +[Full Changelog](https://github.com/skywinder/web3swift/compare/0.3.3...0.3.4) + +## [0.3.3](https://github.com/skywinder/web3swift/tree/0.3.3) (2018-03-05) + +[Full Changelog](https://github.com/skywinder/web3swift/compare/0.3.2...0.3.3) + +## [0.3.2](https://github.com/skywinder/web3swift/tree/0.3.2) (2018-03-03) + +[Full Changelog](https://github.com/skywinder/web3swift/compare/0.3.1...0.3.2) + +## [0.3.1](https://github.com/skywinder/web3swift/tree/0.3.1) (2018-03-01) + +[Full Changelog](https://github.com/skywinder/web3swift/compare/0.3.0...0.3.1) + +## [0.3.0](https://github.com/skywinder/web3swift/tree/0.3.0) (2018-02-27) + +[Full Changelog](https://github.com/skywinder/web3swift/compare/0.2.99...0.3.0) + +## [0.2.99](https://github.com/skywinder/web3swift/tree/0.2.99) (2018-02-27) + +[Full Changelog](https://github.com/skywinder/web3swift/compare/0.2.98...0.2.99) + +## [0.2.98](https://github.com/skywinder/web3swift/tree/0.2.98) (2018-02-27) + +[Full Changelog](https://github.com/skywinder/web3swift/compare/0.2.12...0.2.98) + +## [0.2.12](https://github.com/skywinder/web3swift/tree/0.2.12) (2018-02-01) + +[Full Changelog](https://github.com/skywinder/web3swift/compare/0.2.11...0.2.12) + +## [0.2.11](https://github.com/skywinder/web3swift/tree/0.2.11) (2018-02-01) + +[Full Changelog](https://github.com/skywinder/web3swift/compare/0.2.10...0.2.11) + +## [0.2.10](https://github.com/skywinder/web3swift/tree/0.2.10) (2018-01-31) + +[Full Changelog](https://github.com/skywinder/web3swift/compare/0.2.9...0.2.10) + +## [0.2.9](https://github.com/skywinder/web3swift/tree/0.2.9) (2018-01-29) + +[Full Changelog](https://github.com/skywinder/web3swift/compare/0.2.8...0.2.9) + +## [0.2.8](https://github.com/skywinder/web3swift/tree/0.2.8) (2018-01-18) + +[Full Changelog](https://github.com/skywinder/web3swift/compare/0.2.7...0.2.8) + +## [0.2.7](https://github.com/skywinder/web3swift/tree/0.2.7) (2018-01-15) + +[Full Changelog](https://github.com/skywinder/web3swift/compare/0.2.5...0.2.7) + +## [0.2.5](https://github.com/skywinder/web3swift/tree/0.2.5) (2018-01-12) + +[Full Changelog](https://github.com/skywinder/web3swift/compare/0.2.0...0.2.5) + +## [0.2.0](https://github.com/skywinder/web3swift/tree/0.2.0) (2017-12-30) + +[Full Changelog](https://github.com/skywinder/web3swift/compare/0.1.2...0.2.0) + +## [0.1.2](https://github.com/skywinder/web3swift/tree/0.1.2) (2017-12-27) + +[Full Changelog](https://github.com/skywinder/web3swift/compare/0.1.1...0.1.2) + +## [0.1.1](https://github.com/skywinder/web3swift/tree/0.1.1) (2017-12-26) + +[Full Changelog](https://github.com/skywinder/web3swift/compare/0.1.0...0.1.1) + +## [0.1.0](https://github.com/skywinder/web3swift/tree/0.1.0) (2017-12-26) + +[Full Changelog](https://github.com/skywinder/web3swift/compare/0.0.6...0.1.0) + +## [0.0.6](https://github.com/skywinder/web3swift/tree/0.0.6) (2017-12-26) + +[Full Changelog](https://github.com/skywinder/web3swift/compare/0.0.5...0.0.6) + +## [0.0.5](https://github.com/skywinder/web3swift/tree/0.0.5) (2017-12-21) + +[Full Changelog](https://github.com/skywinder/web3swift/compare/0.0.4...0.0.5) + +## [0.0.4](https://github.com/skywinder/web3swift/tree/0.0.4) (2017-12-21) + +[Full Changelog](https://github.com/skywinder/web3swift/compare/0.0.3...0.0.4) + +## [0.0.3](https://github.com/skywinder/web3swift/tree/0.0.3) (2017-12-20) + +[Full Changelog](https://github.com/skywinder/web3swift/compare/0.0.2...0.0.3) + +## [0.0.2](https://github.com/skywinder/web3swift/tree/0.0.2) (2017-12-20) + +[Full Changelog](https://github.com/skywinder/web3swift/compare/0.0.1...0.0.2) + +## [0.0.1](https://github.com/skywinder/web3swift/tree/0.0.1) (2017-12-19) + +[Full Changelog](https://github.com/skywinder/web3swift/compare/3b32224461f8510e743fa23bccbb437269f98525...0.0.1) diff --git a/CONTRIBUTION.md b/CONTRIBUTION.md new file mode 100644 index 000000000..0d5b18ff9 --- /dev/null +++ b/CONTRIBUTION.md @@ -0,0 +1,75 @@ +# Contribution guide +## Version convention +We’re conforming [default versions convention](https://semver.org/). +So in the `1.0.0` version, each position means the following: +- 1.\*.* — **major release**. Includes breaking changes. As the result, your old code will break with the new version; +- \*.1.* — **minor release**. Added one or more new features to the lib and no breaking changes were introduced. Everything will work as expected, no changes are required in your projects; +- \*.*.1 — **patch release**. Fixed one or more bugs, performed code refactoring, updated documentation or did something with the existing code base that doesn’t include new features nor breaks current ones. + +Though, this library is living within the **three weeks minor release** schedule, please keep in mind that for the sake of avoiding complex merge conflicts, we’re currently taking only **one big feature** per release, so if you want to take some, please drop us a message somewhere (e.g. in [Discord](https://discord.com/invite/8bHCNmhS7x) in #contributors channel) to avoiding reworking it after it’ll be broken by some massive merge and to plan it correctly before you start. + +Critical bug fixes must be marked with the appropriate label in PR and should be processed **within one week** (at least we’ll try our best to make that). + +## Choosing a task +Please take it from the [roadmap](https://hackmd.io/G5znP3xAQY-BVc1X8Y1jSg) or from the [opened issues](https://github.com/skywinder/web3swift/issues?q=is:issue+is:open+sort:updated-desc ""). + +> If you want to make something completely new and purely magical, please drop us a message somewhere before you start (e.g. in [Discord](https://discord.com/invite/8bHCNmhS7x) in #contributors channel). Some features could be already planned but for a later stages or not planned (purposefuly not willing to include) at all. + +## Codestyle guideline +- `swiftlint` check should goes with no warnings. +- Here’s some more detailed and human readable code style [guidelines](https://hackmd.io/8bACoAnTSsKc55Os596yCg) (you can add there some suggestion if you’d like to). +- We use [swift](https://www.swift.org/documentation/api-design-guidelines/) name convention. + +## Tests guideline +1. Cover each new public method with tests. +2. If you’re implementing some big feature encapsulate it in Separate file. +3. Choose one of the two directory to add test case: + * `localTests` — tests which could be ran without needing to connecting to real Ethereum network. + * `remoteTests` — tests which needing connection to real Ethereum network to be ran. +4. Exclude added file from opposite `*.xctestplan` file (e.g. if you’re adding file to `localTests` please exclude it from `RemoteTests.xctestplan`. +5. Add test file to `web3swift.xcodeproj` to make it working within Carthage building system. + +## Hacks & tricks & magic +### TestPlans +In ci/cd we’re using Xcode test plans feature to spread tests to local and remote one. So any time you’re adding any new test suit (file) please exclude it from `LocalTests.xctestplan` rather `RemoteTests.xctestplan` depends on what tests group it included. + +### Swift package manager +Please add any files unused due build process to `excludeFiles` array in `Package.swift`. + +### Carthage +Please do not forget to add & remove all new or dropped files and dependencies in carthage `.xcodeproj` file if you’re working with project anywhere but carthage project. + +### Cocoapods +Please do not forget to add & remove all dependencies within `web3swift.podspec` file. + +### GitHub actions +You’re able to use our github actions checks in your fork without needing to make PR to this repo. To get that just add your branch name to the branch list in file on path `.github/actions/ci.yml` to let the magic happening like follow: + +```yml +on: + push: + branches: + - master + - develop + - hotfix + - #YOUR_REPO_NAME# +``` + +> Please remove your branch from this list before making PR. + +## Good PR checklist +### Code +- [ ] All new functionality is covered by unit tests; +- [ ] All changes are focused on something specific, e.g. 1 feature 1 PR, 1 file refactored in 1 PR (depends on how much was refactored, etc.); +- [ ] No redundant files are added (build cache, Xcode breakpoints settings and so on); +- [ ] Documentation is added or updated. Refactoring a function with no documentation - add documentation. Fixing a bug - updated documentation to reflect changes correctly. + +### Info +- [ ] Short and understandable PR title; +- [ ] Issue or roadmap goal is attached if applicable; +- [ ] PR description filled with detailed explanation of what was changed and reasons for the changes made. + +### Codestyle +- [ ] All public method have `///` styled comments; +- [ ] All magic or nonintuitive internal code parts are clearly explained with additional in inline comments; +- [ ] No commented out code is left in a PR. diff --git a/Cartfile b/Cartfile deleted file mode 100755 index 32101928a..000000000 --- a/Cartfile +++ /dev/null @@ -1,5 +0,0 @@ -github "attaswift/BigInt" ~> 5.0 -github "attaswift/SipHash" ~> 1.2.2 -github "daltoniam/Starscream" ~> 3.1.0 -github "krzyzanowskim/CryptoSwift" ~> 1.0.0 -github "mxcl/PromiseKit" ~> 6.8.4 diff --git a/Cartfile.resolved b/Cartfile.resolved deleted file mode 100644 index 75cdfc0d0..000000000 --- a/Cartfile.resolved +++ /dev/null @@ -1,5 +0,0 @@ -github "attaswift/BigInt" "v5.2.0" -github "attaswift/SipHash" "v1.2.2" -github "daltoniam/Starscream" "3.1.1" -github "krzyzanowskim/CryptoSwift" "1.3.2" -github "mxcl/PromiseKit" "6.13.3" diff --git a/Carthage/Checkouts/BigInt/.codecov.yml b/Carthage/Checkouts/BigInt/.codecov.yml deleted file mode 100644 index e3be23030..000000000 --- a/Carthage/Checkouts/BigInt/.codecov.yml +++ /dev/null @@ -1,14 +0,0 @@ -ignore: -- "/Tests/*" -comment: - layout: "header, diff" - behavior: default - require_changes: no -coverage: - status: - project: - default: - target: auto - threshold: null - base: auto - paths: "Sources/*" diff --git a/Carthage/Checkouts/BigInt/.gitignore b/Carthage/Checkouts/BigInt/.gitignore deleted file mode 100644 index 59f40b169..000000000 --- a/Carthage/Checkouts/BigInt/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/Carthage/Build -/.build -/Packages -xcuserdata -/Package.pins -/Package.resolved diff --git a/Carthage/Checkouts/BigInt/.swift-version b/Carthage/Checkouts/BigInt/.swift-version deleted file mode 100644 index 819e07a22..000000000 --- a/Carthage/Checkouts/BigInt/.swift-version +++ /dev/null @@ -1 +0,0 @@ -5.0 diff --git a/Carthage/Checkouts/BigInt/.travis.yml b/Carthage/Checkouts/BigInt/.travis.yml deleted file mode 100644 index 47753fd23..000000000 --- a/Carthage/Checkouts/BigInt/.travis.yml +++ /dev/null @@ -1,10 +0,0 @@ -language: swift -osx_image: xcode11 -script: -- swift build -- swift test -- xcrun xcodebuild -workspace BigInt.xcworkspace -scheme BigInt-macOS test -- xcrun xcodebuild -workspace BigInt.xcworkspace -scheme BigInt-iOS -destination generic/platform=iOS -- xcrun xcodebuild -workspace BigInt.xcworkspace -scheme BigInt-watchOS -- xcrun xcodebuild -workspace BigInt.xcworkspace -scheme BigInt-tvOS -after_success: bash <(curl -s https://codecov.io/bash) diff --git a/Carthage/Checkouts/BigInt/BigInt.podspec b/Carthage/Checkouts/BigInt/BigInt.podspec deleted file mode 100644 index 758a53727..000000000 --- a/Carthage/Checkouts/BigInt/BigInt.podspec +++ /dev/null @@ -1,17 +0,0 @@ - -Pod::Spec.new do |spec| - spec.name = 'BigInt' - spec.version = '5.2.0' - spec.ios.deployment_target = "8.0" - spec.osx.deployment_target = "10.9" - spec.tvos.deployment_target = "9.0" - spec.watchos.deployment_target = "2.0" - spec.license = { :type => 'MIT', :file => 'LICENSE.md' } - spec.summary = 'Arbitrary-precision arithmetic in pure Swift' - spec.homepage = 'https://github.com/attaswift/BigInt' - spec.author = 'Károly Lőrentey' - spec.source = { :git => 'https://github.com/attaswift/BigInt.git', :tag => 'v' + String(spec.version) } - spec.source_files = 'Sources/*.swift' - spec.social_media_url = 'https://twitter.com/lorentey' - spec.documentation_url = 'http://attaswift.github.io/BigInt/' -end diff --git a/Carthage/Checkouts/BigInt/BigInt.xcodeproj/project.pbxproj b/Carthage/Checkouts/BigInt/BigInt.xcodeproj/project.pbxproj deleted file mode 100644 index 9e27c6bf6..000000000 --- a/Carthage/Checkouts/BigInt/BigInt.xcodeproj/project.pbxproj +++ /dev/null @@ -1,1303 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 48; - objects = { - -/* Begin PBXBuildFile section */ - BB241C441DDB70600067F917 /* Addition.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C301DDB70600067F917 /* Addition.swift */; }; - BB241C451DDB70600067F917 /* Bitwise Ops.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C311DDB70600067F917 /* Bitwise Ops.swift */; }; - BB241C461DDB70600067F917 /* Comparable.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C321DDB70600067F917 /* Comparable.swift */; }; - BB241C471DDB70600067F917 /* Data Conversion.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C331DDB70600067F917 /* Data Conversion.swift */; }; - BB241C481DDB70600067F917 /* Division.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C341DDB70600067F917 /* Division.swift */; }; - BB241C491DDB70600067F917 /* Exponentiation.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C351DDB70600067F917 /* Exponentiation.swift */; }; - BB241C4A1DDB70600067F917 /* GCD.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C361DDB70600067F917 /* GCD.swift */; }; - BB241C4B1DDB70600067F917 /* Hashable.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C371DDB70600067F917 /* Hashable.swift */; }; - BB241C4C1DDB70600067F917 /* Multiplication.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C381DDB70600067F917 /* Multiplication.swift */; }; - BB241C4D1DDB70600067F917 /* Prime Test.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C391DDB70600067F917 /* Prime Test.swift */; }; - BB241C4E1DDB70600067F917 /* String Conversion.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C3A1DDB70600067F917 /* String Conversion.swift */; }; - BB241C4F1DDB70600067F917 /* Random.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C3B1DDB70600067F917 /* Random.swift */; }; - BB241C501DDB70600067F917 /* Shifts.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C3C1DDB70600067F917 /* Shifts.swift */; }; - BB241C511DDB70600067F917 /* Square Root.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C3D1DDB70600067F917 /* Square Root.swift */; }; - BB241C521DDB70600067F917 /* Subtraction.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C3E1DDB70600067F917 /* Subtraction.swift */; }; - BB241C531DDB70600067F917 /* BigUInt.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C3F1DDB70600067F917 /* BigUInt.swift */; }; - BB241C651DDB70B00067F917 /* BigInt.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BBB55AD41C8F88F20050DDA9 /* BigInt.framework */; }; - BB241C6F1DDB71910067F917 /* BigUInt.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C3F1DDB70600067F917 /* BigUInt.swift */; }; - BB241C701DDB71910067F917 /* Comparable.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C321DDB70600067F917 /* Comparable.swift */; }; - BB241C711DDB71910067F917 /* Hashable.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C371DDB70600067F917 /* Hashable.swift */; }; - BB241C721DDB71910067F917 /* Data Conversion.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C331DDB70600067F917 /* Data Conversion.swift */; }; - BB241C731DDB71910067F917 /* Addition.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C301DDB70600067F917 /* Addition.swift */; }; - BB241C741DDB71910067F917 /* Subtraction.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C3E1DDB70600067F917 /* Subtraction.swift */; }; - BB241C751DDB71910067F917 /* Multiplication.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C381DDB70600067F917 /* Multiplication.swift */; }; - BB241C761DDB71910067F917 /* Division.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C341DDB70600067F917 /* Division.swift */; }; - BB241C771DDB71910067F917 /* Exponentiation.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C351DDB70600067F917 /* Exponentiation.swift */; }; - BB241C781DDB71910067F917 /* Bitwise Ops.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C311DDB70600067F917 /* Bitwise Ops.swift */; }; - BB241C791DDB71910067F917 /* Shifts.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C3C1DDB70600067F917 /* Shifts.swift */; }; - BB241C7A1DDB71910067F917 /* Square Root.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C3D1DDB70600067F917 /* Square Root.swift */; }; - BB241C7B1DDB71910067F917 /* GCD.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C361DDB70600067F917 /* GCD.swift */; }; - BB241C7C1DDB71910067F917 /* Prime Test.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C391DDB70600067F917 /* Prime Test.swift */; }; - BB241C7D1DDB71910067F917 /* String Conversion.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C3A1DDB70600067F917 /* String Conversion.swift */; }; - BB241C7E1DDB71910067F917 /* Random.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C3B1DDB70600067F917 /* Random.swift */; }; - BB241C831DDB71920067F917 /* BigUInt.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C3F1DDB70600067F917 /* BigUInt.swift */; }; - BB241C841DDB71920067F917 /* Comparable.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C321DDB70600067F917 /* Comparable.swift */; }; - BB241C851DDB71920067F917 /* Hashable.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C371DDB70600067F917 /* Hashable.swift */; }; - BB241C861DDB71920067F917 /* Data Conversion.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C331DDB70600067F917 /* Data Conversion.swift */; }; - BB241C871DDB71920067F917 /* Addition.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C301DDB70600067F917 /* Addition.swift */; }; - BB241C881DDB71920067F917 /* Subtraction.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C3E1DDB70600067F917 /* Subtraction.swift */; }; - BB241C891DDB71920067F917 /* Multiplication.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C381DDB70600067F917 /* Multiplication.swift */; }; - BB241C8A1DDB71920067F917 /* Division.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C341DDB70600067F917 /* Division.swift */; }; - BB241C8B1DDB71920067F917 /* Exponentiation.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C351DDB70600067F917 /* Exponentiation.swift */; }; - BB241C8C1DDB71920067F917 /* Bitwise Ops.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C311DDB70600067F917 /* Bitwise Ops.swift */; }; - BB241C8D1DDB71920067F917 /* Shifts.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C3C1DDB70600067F917 /* Shifts.swift */; }; - BB241C8E1DDB71920067F917 /* Square Root.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C3D1DDB70600067F917 /* Square Root.swift */; }; - BB241C8F1DDB71920067F917 /* GCD.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C361DDB70600067F917 /* GCD.swift */; }; - BB241C901DDB71920067F917 /* Prime Test.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C391DDB70600067F917 /* Prime Test.swift */; }; - BB241C911DDB71920067F917 /* String Conversion.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C3A1DDB70600067F917 /* String Conversion.swift */; }; - BB241C921DDB71920067F917 /* Random.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C3B1DDB70600067F917 /* Random.swift */; }; - BB241C971DDB71920067F917 /* BigUInt.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C3F1DDB70600067F917 /* BigUInt.swift */; }; - BB241C981DDB71920067F917 /* Comparable.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C321DDB70600067F917 /* Comparable.swift */; }; - BB241C991DDB71920067F917 /* Hashable.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C371DDB70600067F917 /* Hashable.swift */; }; - BB241C9A1DDB71920067F917 /* Data Conversion.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C331DDB70600067F917 /* Data Conversion.swift */; }; - BB241C9B1DDB71920067F917 /* Addition.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C301DDB70600067F917 /* Addition.swift */; }; - BB241C9C1DDB71920067F917 /* Subtraction.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C3E1DDB70600067F917 /* Subtraction.swift */; }; - BB241C9D1DDB71920067F917 /* Multiplication.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C381DDB70600067F917 /* Multiplication.swift */; }; - BB241C9E1DDB71920067F917 /* Division.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C341DDB70600067F917 /* Division.swift */; }; - BB241C9F1DDB71920067F917 /* Exponentiation.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C351DDB70600067F917 /* Exponentiation.swift */; }; - BB241CA01DDB71920067F917 /* Bitwise Ops.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C311DDB70600067F917 /* Bitwise Ops.swift */; }; - BB241CA11DDB71920067F917 /* Shifts.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C3C1DDB70600067F917 /* Shifts.swift */; }; - BB241CA21DDB71920067F917 /* Square Root.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C3D1DDB70600067F917 /* Square Root.swift */; }; - BB241CA31DDB71920067F917 /* GCD.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C361DDB70600067F917 /* GCD.swift */; }; - BB241CA41DDB71920067F917 /* Prime Test.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C391DDB70600067F917 /* Prime Test.swift */; }; - BB241CA51DDB71920067F917 /* String Conversion.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C3A1DDB70600067F917 /* String Conversion.swift */; }; - BB241CA61DDB71920067F917 /* Random.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C3B1DDB70600067F917 /* Random.swift */; }; - BB241CBB1DDB71A50067F917 /* ProfileTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C5A1DDB70690067F917 /* ProfileTests.swift */; }; - BB241CC51DDB71A60067F917 /* ProfileTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C5A1DDB70690067F917 /* ProfileTests.swift */; }; - BB241CDC1DDB79E20067F917 /* BigUIntTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C571DDB70690067F917 /* BigUIntTests.swift */; }; - BB241CE41DDB79E30067F917 /* BigUIntTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C571DDB70690067F917 /* BigUIntTests.swift */; }; - BB4273F61F24AFCC00065766 /* Tools.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB4273F41F24AFC800065766 /* Tools.swift */; }; - BB4273F71F24AFCD00065766 /* Tools.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB4273F41F24AFC800065766 /* Tools.swift */; }; - BB4273F81F24AFCD00065766 /* Tools.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB4273F41F24AFC800065766 /* Tools.swift */; }; - BB4273F91F24AFCE00065766 /* Tools.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB4273F41F24AFC800065766 /* Tools.swift */; }; - BB64CD611F1D65D000C1B077 /* BigInt.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C2F1DDB70600067F917 /* BigInt.swift */; }; - BB9889A51F3E5C3100014740 /* Strideable.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB9889A41F3E5C3100014740 /* Strideable.swift */; }; - BB9889A61F3E5C3100014740 /* Strideable.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB9889A41F3E5C3100014740 /* Strideable.swift */; }; - BB9889A71F3E5C3100014740 /* Strideable.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB9889A41F3E5C3100014740 /* Strideable.swift */; }; - BB9889A81F3E5C3100014740 /* Strideable.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB9889A41F3E5C3100014740 /* Strideable.swift */; }; - BB9889AA1F3E5CC600014740 /* Integer Conversion.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB9889A91F3E5CC600014740 /* Integer Conversion.swift */; }; - BB9889AB1F3E5CC600014740 /* Integer Conversion.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB9889A91F3E5CC600014740 /* Integer Conversion.swift */; }; - BB9889AC1F3E5CC600014740 /* Integer Conversion.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB9889A91F3E5CC600014740 /* Integer Conversion.swift */; }; - BB9889AD1F3E5CC600014740 /* Integer Conversion.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB9889A91F3E5CC600014740 /* Integer Conversion.swift */; }; - BB99168F1F32610700CCFDDC /* BigIntTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C561DDB70690067F917 /* BigIntTests.swift */; }; - BB9916901F32610A00CCFDDC /* BigUIntTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C571DDB70690067F917 /* BigUIntTests.swift */; }; - BB9916911F33C32000CCFDDC /* WordTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBEAE4DC1F28C37800F4E329 /* WordTests.swift */; }; - BBABCDD21F3E17A8009CA8BC /* Floating Point Conversion.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBABCDD11F3E17A8009CA8BC /* Floating Point Conversion.swift */; }; - BBABCDD31F3E17A8009CA8BC /* Floating Point Conversion.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBABCDD11F3E17A8009CA8BC /* Floating Point Conversion.swift */; }; - BBABCDD41F3E17A8009CA8BC /* Floating Point Conversion.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBABCDD11F3E17A8009CA8BC /* Floating Point Conversion.swift */; }; - BBABCDD51F3E17A8009CA8BC /* Floating Point Conversion.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBABCDD11F3E17A8009CA8BC /* Floating Point Conversion.swift */; }; - BBABCDD71F3E2038009CA8BC /* Words and Bits.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBABCDD61F3E2038009CA8BC /* Words and Bits.swift */; }; - BBABCDD81F3E2038009CA8BC /* Words and Bits.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBABCDD61F3E2038009CA8BC /* Words and Bits.swift */; }; - BBABCDD91F3E2038009CA8BC /* Words and Bits.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBABCDD61F3E2038009CA8BC /* Words and Bits.swift */; }; - BBABCDDA1F3E2038009CA8BC /* Words and Bits.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBABCDD61F3E2038009CA8BC /* Words and Bits.swift */; }; - BBB55ABD1C8F80020050DDA9 /* BigInt.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BBB55AB21C8F80020050DDA9 /* BigInt.framework */; }; - BBB55ADE1C8F88F20050DDA9 /* BigInt.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BBB55AD41C8F88F20050DDA9 /* BigInt.framework */; }; - BBB55B081C8F8CBC0050DDA9 /* BigInt.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BBB55AFE1C8F8CBB0050DDA9 /* BigInt.framework */; }; - BBC944371F24C25A00ED6C30 /* BigInt.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C2F1DDB70600067F917 /* BigInt.swift */; }; - BBC944381F24C25B00ED6C30 /* BigInt.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C2F1DDB70600067F917 /* BigInt.swift */; }; - BBC944391F24C25C00ED6C30 /* BigInt.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C2F1DDB70600067F917 /* BigInt.swift */; }; - BBC9443A1F24C27E00ED6C30 /* BigIntTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C561DDB70690067F917 /* BigIntTests.swift */; }; - BBC9443C1F24C27F00ED6C30 /* BigIntTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C561DDB70690067F917 /* BigIntTests.swift */; }; - BBE4CA4E1F3DA5AB0062A281 /* Codable.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBE4CA4D1F3DA5AB0062A281 /* Codable.swift */; }; - BBE4CA4F1F3DAD380062A281 /* Codable.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBE4CA4D1F3DA5AB0062A281 /* Codable.swift */; }; - BBE4CA501F3DAD390062A281 /* Codable.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBE4CA4D1F3DA5AB0062A281 /* Codable.swift */; }; - BBE4CA511F3DAD390062A281 /* Codable.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBE4CA4D1F3DA5AB0062A281 /* Codable.swift */; }; - BBEAE4DD1F28C37800F4E329 /* WordTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBEAE4DC1F28C37800F4E329 /* WordTests.swift */; }; - BBEAE4DF1F28C37800F4E329 /* WordTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBEAE4DC1F28C37800F4E329 /* WordTests.swift */; }; - BBF16BD51F2BA51B00402089 /* ProfileTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB241C5A1DDB70690067F917 /* ProfileTests.swift */; }; -/* End PBXBuildFile section */ - -/* Begin PBXContainerItemProxy section */ - BB241C621DDB70B00067F917 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = BBB55AA91C8F80020050DDA9 /* Project object */; - proxyType = 1; - remoteGlobalIDString = BBB55AD31C8F88F20050DDA9; - remoteInfo = BigInt; - }; - BBB55ABE1C8F80020050DDA9 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = BBB55AA91C8F80020050DDA9 /* Project object */; - proxyType = 1; - remoteGlobalIDString = BBB55AB11C8F80020050DDA9; - remoteInfo = BigInt; - }; - BBB55ADF1C8F88F20050DDA9 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = BBB55AA91C8F80020050DDA9 /* Project object */; - proxyType = 1; - remoteGlobalIDString = BBB55AD31C8F88F20050DDA9; - remoteInfo = BigInt; - }; - BBB55B091C8F8CBC0050DDA9 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = BBB55AA91C8F80020050DDA9 /* Project object */; - proxyType = 1; - remoteGlobalIDString = BBB55AFD1C8F8CBB0050DDA9; - remoteInfo = BigInt; - }; -/* End PBXContainerItemProxy section */ - -/* Begin PBXFileReference section */ - BB241BC51DD9F6490067F917 /* Package.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Package.swift; sourceTree = ""; }; - BB241BC71DD9F7D60067F917 /* BigInt.podspec */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; path = BigInt.podspec; sourceTree = ""; }; - BB241C2F1DDB70600067F917 /* BigInt.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BigInt.swift; sourceTree = ""; }; - BB241C301DDB70600067F917 /* Addition.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Addition.swift; sourceTree = ""; }; - BB241C311DDB70600067F917 /* Bitwise Ops.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Bitwise Ops.swift"; sourceTree = ""; }; - BB241C321DDB70600067F917 /* Comparable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Comparable.swift; sourceTree = ""; }; - BB241C331DDB70600067F917 /* Data Conversion.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Data Conversion.swift"; sourceTree = ""; }; - BB241C341DDB70600067F917 /* Division.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Division.swift; sourceTree = ""; }; - BB241C351DDB70600067F917 /* Exponentiation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Exponentiation.swift; sourceTree = ""; }; - BB241C361DDB70600067F917 /* GCD.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GCD.swift; sourceTree = ""; }; - BB241C371DDB70600067F917 /* Hashable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Hashable.swift; sourceTree = ""; }; - BB241C381DDB70600067F917 /* Multiplication.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Multiplication.swift; sourceTree = ""; }; - BB241C391DDB70600067F917 /* Prime Test.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Prime Test.swift"; sourceTree = ""; }; - BB241C3A1DDB70600067F917 /* String Conversion.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "String Conversion.swift"; sourceTree = ""; }; - BB241C3B1DDB70600067F917 /* Random.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Random.swift; sourceTree = ""; }; - BB241C3C1DDB70600067F917 /* Shifts.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Shifts.swift; sourceTree = ""; }; - BB241C3D1DDB70600067F917 /* Square Root.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Square Root.swift"; sourceTree = ""; }; - BB241C3E1DDB70600067F917 /* Subtraction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Subtraction.swift; sourceTree = ""; }; - BB241C3F1DDB70600067F917 /* BigUInt.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BigUInt.swift; sourceTree = ""; }; - BB241C561DDB70690067F917 /* BigIntTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BigIntTests.swift; sourceTree = ""; }; - BB241C571DDB70690067F917 /* BigUIntTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BigUIntTests.swift; sourceTree = ""; }; - BB241C5A1DDB70690067F917 /* ProfileTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProfileTests.swift; sourceTree = ""; }; - BB241C6A1DDB70B00067F917 /* BigInt Benchmark.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "BigInt Benchmark.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; - BB241CE81DDB7B620067F917 /* CHANGELOG.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = CHANGELOG.md; sourceTree = ""; }; - BB241CE91DDB7B620067F917 /* Demo.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = Demo.playground; sourceTree = ""; }; - BB241CEA1DDB7B620067F917 /* generate-docs.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = "generate-docs.sh"; sourceTree = ""; }; - BB241CF01DDB84210067F917 /* .codecov.yml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = .codecov.yml; sourceTree = ""; }; - BB4273F41F24AFC800065766 /* Tools.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Tools.swift; sourceTree = ""; }; - BB9889A41F3E5C3100014740 /* Strideable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Strideable.swift; sourceTree = ""; }; - BB9889A91F3E5CC600014740 /* Integer Conversion.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Integer Conversion.swift"; sourceTree = ""; }; - BBABCDD11F3E17A8009CA8BC /* Floating Point Conversion.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Floating Point Conversion.swift"; sourceTree = ""; }; - BBABCDD61F3E2038009CA8BC /* Words and Bits.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Words and Bits.swift"; sourceTree = ""; }; - BBB55AB21C8F80020050DDA9 /* BigInt.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = BigInt.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - BBB55AB71C8F80020050DDA9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - BBB55ABC1C8F80020050DDA9 /* BigInt-Test.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "BigInt-Test.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; - BBB55AC31C8F80020050DDA9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - BBB55ACC1C8F80660050DDA9 /* version.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = version.xcconfig; sourceTree = ""; }; - BBB55AD41C8F88F20050DDA9 /* BigInt.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = BigInt.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - BBB55ADD1C8F88F20050DDA9 /* BigInt-Test.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "BigInt-Test.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; - BBB55AF11C8F8BE00050DDA9 /* BigInt.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = BigInt.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - BBB55AFE1C8F8CBB0050DDA9 /* BigInt.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = BigInt.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - BBB55B071C8F8CBB0050DDA9 /* BigInt-Test.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "BigInt-Test.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; - BBB55B1C1C8F90F60050DDA9 /* .travis.yml */ = {isa = PBXFileReference; lastKnownFileType = text; path = .travis.yml; sourceTree = ""; }; - BBB55B1D1C8F9E850050DDA9 /* LICENSE.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = LICENSE.md; sourceTree = ""; }; - BBB55B1E1C8F9E920050DDA9 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; - BBE4CA4D1F3DA5AB0062A281 /* Codable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Codable.swift; sourceTree = ""; }; - BBEAE4DC1F28C37800F4E329 /* WordTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WordTests.swift; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - BB241C641DDB70B00067F917 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - BB241C651DDB70B00067F917 /* BigInt.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - BBB55AAE1C8F80020050DDA9 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - BBB55AB91C8F80020050DDA9 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - BBB55ABD1C8F80020050DDA9 /* BigInt.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - BBB55AD01C8F88F20050DDA9 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - BBB55ADA1C8F88F20050DDA9 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - BBB55ADE1C8F88F20050DDA9 /* BigInt.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - BBB55AED1C8F8BE00050DDA9 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - BBB55AFA1C8F8CBB0050DDA9 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - BBB55B041C8F8CBB0050DDA9 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - BBB55B081C8F8CBC0050DDA9 /* BigInt.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - BB241CCB1DDB71DB0067F917 /* Frameworks */ = { - isa = PBXGroup; - children = ( - ); - name = Frameworks; - sourceTree = ""; - }; - BBB55AA81C8F80020050DDA9 = { - isa = PBXGroup; - children = ( - BBB55B1E1C8F9E920050DDA9 /* README.md */, - BBB55B1D1C8F9E850050DDA9 /* LICENSE.md */, - BB241CE81DDB7B620067F917 /* CHANGELOG.md */, - BB241BC51DD9F6490067F917 /* Package.swift */, - BB241BC71DD9F7D60067F917 /* BigInt.podspec */, - BBB55B1C1C8F90F60050DDA9 /* .travis.yml */, - BB241CF01DDB84210067F917 /* .codecov.yml */, - BBB55ACC1C8F80660050DDA9 /* version.xcconfig */, - BB241CEA1DDB7B620067F917 /* generate-docs.sh */, - BB241CE91DDB7B620067F917 /* Demo.playground */, - BBB55AB41C8F80020050DDA9 /* Sources */, - BBB55AC01C8F80020050DDA9 /* Tests */, - BBB55AB31C8F80020050DDA9 /* Products */, - BB241CCB1DDB71DB0067F917 /* Frameworks */, - ); - sourceTree = ""; - }; - BBB55AB31C8F80020050DDA9 /* Products */ = { - isa = PBXGroup; - children = ( - BBB55AB21C8F80020050DDA9 /* BigInt.framework */, - BBB55ABC1C8F80020050DDA9 /* BigInt-Test.xctest */, - BBB55AD41C8F88F20050DDA9 /* BigInt.framework */, - BBB55ADD1C8F88F20050DDA9 /* BigInt-Test.xctest */, - BBB55AF11C8F8BE00050DDA9 /* BigInt.framework */, - BBB55AFE1C8F8CBB0050DDA9 /* BigInt.framework */, - BBB55B071C8F8CBB0050DDA9 /* BigInt-Test.xctest */, - BB241C6A1DDB70B00067F917 /* BigInt Benchmark.xctest */, - ); - name = Products; - sourceTree = ""; - }; - BBB55AB41C8F80020050DDA9 /* Sources */ = { - isa = PBXGroup; - children = ( - BB241C3F1DDB70600067F917 /* BigUInt.swift */, - BB241C2F1DDB70600067F917 /* BigInt.swift */, - BBABCDD61F3E2038009CA8BC /* Words and Bits.swift */, - BB9889A91F3E5CC600014740 /* Integer Conversion.swift */, - BBABCDD11F3E17A8009CA8BC /* Floating Point Conversion.swift */, - BB241C3A1DDB70600067F917 /* String Conversion.swift */, - BB241C331DDB70600067F917 /* Data Conversion.swift */, - BB241C321DDB70600067F917 /* Comparable.swift */, - BB241C371DDB70600067F917 /* Hashable.swift */, - BBE4CA4D1F3DA5AB0062A281 /* Codable.swift */, - BB241C301DDB70600067F917 /* Addition.swift */, - BB241C3E1DDB70600067F917 /* Subtraction.swift */, - BB9889A41F3E5C3100014740 /* Strideable.swift */, - BB241C381DDB70600067F917 /* Multiplication.swift */, - BB241C341DDB70600067F917 /* Division.swift */, - BB241C351DDB70600067F917 /* Exponentiation.swift */, - BB241C311DDB70600067F917 /* Bitwise Ops.swift */, - BB241C3C1DDB70600067F917 /* Shifts.swift */, - BB241C3D1DDB70600067F917 /* Square Root.swift */, - BB241C361DDB70600067F917 /* GCD.swift */, - BB241C391DDB70600067F917 /* Prime Test.swift */, - BB241C3B1DDB70600067F917 /* Random.swift */, - BBB55AB71C8F80020050DDA9 /* Info.plist */, - ); - path = Sources; - sourceTree = ""; - }; - BBB55AC01C8F80020050DDA9 /* Tests */ = { - isa = PBXGroup; - children = ( - BB241C561DDB70690067F917 /* BigIntTests.swift */, - BB241C571DDB70690067F917 /* BigUIntTests.swift */, - BBEAE4DC1F28C37800F4E329 /* WordTests.swift */, - BB241C5A1DDB70690067F917 /* ProfileTests.swift */, - BB4273F41F24AFC800065766 /* Tools.swift */, - BBB55AC31C8F80020050DDA9 /* Info.plist */, - ); - name = Tests; - path = Tests/BigIntTests; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXHeadersBuildPhase section */ - BBB55AAF1C8F80020050DDA9 /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - BBB55AD11C8F88F20050DDA9 /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - BBB55AEE1C8F8BE00050DDA9 /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - BBB55AFB1C8F8CBB0050DDA9 /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXHeadersBuildPhase section */ - -/* Begin PBXNativeTarget section */ - BB241C601DDB70B00067F917 /* BigInt Benchmark */ = { - isa = PBXNativeTarget; - buildConfigurationList = BB241C671DDB70B00067F917 /* Build configuration list for PBXNativeTarget "BigInt Benchmark" */; - buildPhases = ( - BB241C631DDB70B00067F917 /* Sources */, - BB241C641DDB70B00067F917 /* Frameworks */, - BB241C661DDB70B00067F917 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - BB241C611DDB70B00067F917 /* PBXTargetDependency */, - ); - name = "BigInt Benchmark"; - productName = BigIntTests; - productReference = BB241C6A1DDB70B00067F917 /* BigInt Benchmark.xctest */; - productType = "com.apple.product-type.bundle.unit-test"; - }; - BBB55AB11C8F80020050DDA9 /* BigInt-iOS */ = { - isa = PBXNativeTarget; - buildConfigurationList = BBB55AC61C8F80020050DDA9 /* Build configuration list for PBXNativeTarget "BigInt-iOS" */; - buildPhases = ( - BBB55AAD1C8F80020050DDA9 /* Sources */, - BBB55AAE1C8F80020050DDA9 /* Frameworks */, - BBB55AAF1C8F80020050DDA9 /* Headers */, - BBB55AB01C8F80020050DDA9 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = "BigInt-iOS"; - productName = BigInt; - productReference = BBB55AB21C8F80020050DDA9 /* BigInt.framework */; - productType = "com.apple.product-type.framework"; - }; - BBB55ABB1C8F80020050DDA9 /* BigInt iOS Tests */ = { - isa = PBXNativeTarget; - buildConfigurationList = BBB55AC91C8F80020050DDA9 /* Build configuration list for PBXNativeTarget "BigInt iOS Tests" */; - buildPhases = ( - BBB55AB81C8F80020050DDA9 /* Sources */, - BBB55AB91C8F80020050DDA9 /* Frameworks */, - BBB55ABA1C8F80020050DDA9 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - BBB55ABF1C8F80020050DDA9 /* PBXTargetDependency */, - ); - name = "BigInt iOS Tests"; - productName = BigIntTests; - productReference = BBB55ABC1C8F80020050DDA9 /* BigInt-Test.xctest */; - productType = "com.apple.product-type.bundle.unit-test"; - }; - BBB55AD31C8F88F20050DDA9 /* BigInt-macOS */ = { - isa = PBXNativeTarget; - buildConfigurationList = BBB55AE51C8F88F20050DDA9 /* Build configuration list for PBXNativeTarget "BigInt-macOS" */; - buildPhases = ( - BBB55ACF1C8F88F20050DDA9 /* Sources */, - BBB55AD01C8F88F20050DDA9 /* Frameworks */, - BBB55AD11C8F88F20050DDA9 /* Headers */, - BBB55AD21C8F88F20050DDA9 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = "BigInt-macOS"; - productName = BigInt; - productReference = BBB55AD41C8F88F20050DDA9 /* BigInt.framework */; - productType = "com.apple.product-type.framework"; - }; - BBB55ADC1C8F88F20050DDA9 /* BigInt macOS Tests */ = { - isa = PBXNativeTarget; - buildConfigurationList = BBB55AE81C8F88F20050DDA9 /* Build configuration list for PBXNativeTarget "BigInt macOS Tests" */; - buildPhases = ( - BBB55AD91C8F88F20050DDA9 /* Sources */, - BBB55ADA1C8F88F20050DDA9 /* Frameworks */, - BBB55ADB1C8F88F20050DDA9 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - BBB55AE01C8F88F20050DDA9 /* PBXTargetDependency */, - ); - name = "BigInt macOS Tests"; - productName = BigIntTests; - productReference = BBB55ADD1C8F88F20050DDA9 /* BigInt-Test.xctest */; - productType = "com.apple.product-type.bundle.unit-test"; - }; - BBB55AF01C8F8BE00050DDA9 /* BigInt-watchOS */ = { - isa = PBXNativeTarget; - buildConfigurationList = BBB55AF61C8F8BE00050DDA9 /* Build configuration list for PBXNativeTarget "BigInt-watchOS" */; - buildPhases = ( - BBB55AEC1C8F8BE00050DDA9 /* Sources */, - BBB55AED1C8F8BE00050DDA9 /* Frameworks */, - BBB55AEE1C8F8BE00050DDA9 /* Headers */, - BBB55AEF1C8F8BE00050DDA9 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = "BigInt-watchOS"; - productName = BigInt; - productReference = BBB55AF11C8F8BE00050DDA9 /* BigInt.framework */; - productType = "com.apple.product-type.framework"; - }; - BBB55AFD1C8F8CBB0050DDA9 /* BigInt-tvOS */ = { - isa = PBXNativeTarget; - buildConfigurationList = BBB55B0F1C8F8CBC0050DDA9 /* Build configuration list for PBXNativeTarget "BigInt-tvOS" */; - buildPhases = ( - BBB55AF91C8F8CBB0050DDA9 /* Sources */, - BBB55AFA1C8F8CBB0050DDA9 /* Frameworks */, - BBB55AFB1C8F8CBB0050DDA9 /* Headers */, - BBB55AFC1C8F8CBB0050DDA9 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = "BigInt-tvOS"; - productName = BigInt; - productReference = BBB55AFE1C8F8CBB0050DDA9 /* BigInt.framework */; - productType = "com.apple.product-type.framework"; - }; - BBB55B061C8F8CBB0050DDA9 /* BigInt tvOS Tests */ = { - isa = PBXNativeTarget; - buildConfigurationList = BBB55B121C8F8CBC0050DDA9 /* Build configuration list for PBXNativeTarget "BigInt tvOS Tests" */; - buildPhases = ( - BBB55B031C8F8CBB0050DDA9 /* Sources */, - BBB55B041C8F8CBB0050DDA9 /* Frameworks */, - BBB55B051C8F8CBB0050DDA9 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - BBB55B0A1C8F8CBC0050DDA9 /* PBXTargetDependency */, - ); - name = "BigInt tvOS Tests"; - productName = BigIntTests; - productReference = BBB55B071C8F8CBB0050DDA9 /* BigInt-Test.xctest */; - productType = "com.apple.product-type.bundle.unit-test"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - BBB55AA91C8F80020050DDA9 /* Project object */ = { - isa = PBXProject; - attributes = { - LastSwiftUpdateCheck = 0730; - LastUpgradeCheck = 1100; - ORGANIZATIONNAME = "Károly Lőrentey"; - TargetAttributes = { - BBB55AB11C8F80020050DDA9 = { - CreatedOnToolsVersion = 7.3; - LastSwiftMigration = 1020; - }; - BBB55ABB1C8F80020050DDA9 = { - CreatedOnToolsVersion = 7.3; - LastSwiftMigration = 1020; - }; - BBB55AD31C8F88F20050DDA9 = { - CreatedOnToolsVersion = 7.3; - LastSwiftMigration = 1020; - }; - BBB55ADC1C8F88F20050DDA9 = { - CreatedOnToolsVersion = 7.3; - LastSwiftMigration = 1020; - }; - BBB55AF01C8F8BE00050DDA9 = { - CreatedOnToolsVersion = 7.3; - LastSwiftMigration = 1020; - }; - BBB55AFD1C8F8CBB0050DDA9 = { - CreatedOnToolsVersion = 7.3; - }; - BBB55B061C8F8CBB0050DDA9 = { - CreatedOnToolsVersion = 7.3; - }; - }; - }; - buildConfigurationList = BBB55AAC1C8F80020050DDA9 /* Build configuration list for PBXProject "BigInt" */; - compatibilityVersion = "Xcode 8.0"; - developmentRegion = en; - hasScannedForEncodings = 0; - knownRegions = ( - en, - Base, - ); - mainGroup = BBB55AA81C8F80020050DDA9; - productRefGroup = BBB55AB31C8F80020050DDA9 /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - BBB55AB11C8F80020050DDA9 /* BigInt-iOS */, - BBB55AD31C8F88F20050DDA9 /* BigInt-macOS */, - BBB55AF01C8F8BE00050DDA9 /* BigInt-watchOS */, - BBB55AFD1C8F8CBB0050DDA9 /* BigInt-tvOS */, - BBB55ABB1C8F80020050DDA9 /* BigInt iOS Tests */, - BBB55ADC1C8F88F20050DDA9 /* BigInt macOS Tests */, - BBB55B061C8F8CBB0050DDA9 /* BigInt tvOS Tests */, - BB241C601DDB70B00067F917 /* BigInt Benchmark */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - BB241C661DDB70B00067F917 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - BBB55AB01C8F80020050DDA9 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - BBB55ABA1C8F80020050DDA9 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - BBB55AD21C8F88F20050DDA9 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - BBB55ADB1C8F88F20050DDA9 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - BBB55AEF1C8F8BE00050DDA9 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - BBB55AFC1C8F8CBB0050DDA9 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - BBB55B051C8F8CBB0050DDA9 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - BB241C631DDB70B00067F917 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - BB4273F91F24AFCE00065766 /* Tools.swift in Sources */, - BBF16BD51F2BA51B00402089 /* ProfileTests.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - BBB55AAD1C8F80020050DDA9 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - BB241C441DDB70600067F917 /* Addition.swift in Sources */, - BB241C531DDB70600067F917 /* BigUInt.swift in Sources */, - BB241C4F1DDB70600067F917 /* Random.swift in Sources */, - BBABCDD71F3E2038009CA8BC /* Words and Bits.swift in Sources */, - BBC944391F24C25C00ED6C30 /* BigInt.swift in Sources */, - BB241C4D1DDB70600067F917 /* Prime Test.swift in Sources */, - BBABCDD21F3E17A8009CA8BC /* Floating Point Conversion.swift in Sources */, - BB241C4B1DDB70600067F917 /* Hashable.swift in Sources */, - BB241C4A1DDB70600067F917 /* GCD.swift in Sources */, - BB9889AA1F3E5CC600014740 /* Integer Conversion.swift in Sources */, - BB241C4E1DDB70600067F917 /* String Conversion.swift in Sources */, - BB241C481DDB70600067F917 /* Division.swift in Sources */, - BB241C501DDB70600067F917 /* Shifts.swift in Sources */, - BB241C521DDB70600067F917 /* Subtraction.swift in Sources */, - BB241C4C1DDB70600067F917 /* Multiplication.swift in Sources */, - BB9889A51F3E5C3100014740 /* Strideable.swift in Sources */, - BB241C511DDB70600067F917 /* Square Root.swift in Sources */, - BB241C471DDB70600067F917 /* Data Conversion.swift in Sources */, - BB241C461DDB70600067F917 /* Comparable.swift in Sources */, - BBE4CA4E1F3DA5AB0062A281 /* Codable.swift in Sources */, - BB241C491DDB70600067F917 /* Exponentiation.swift in Sources */, - BB241C451DDB70600067F917 /* Bitwise Ops.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - BBB55AB81C8F80020050DDA9 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - BBC9443A1F24C27E00ED6C30 /* BigIntTests.swift in Sources */, - BB241CBB1DDB71A50067F917 /* ProfileTests.swift in Sources */, - BB4273F61F24AFCC00065766 /* Tools.swift in Sources */, - BBEAE4DD1F28C37800F4E329 /* WordTests.swift in Sources */, - BB241CE41DDB79E30067F917 /* BigUIntTests.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - BBB55ACF1C8F88F20050DDA9 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - BB241C8C1DDB71920067F917 /* Bitwise Ops.swift in Sources */, - BB241C921DDB71920067F917 /* Random.swift in Sources */, - BB241C901DDB71920067F917 /* Prime Test.swift in Sources */, - BBABCDD81F3E2038009CA8BC /* Words and Bits.swift in Sources */, - BB64CD611F1D65D000C1B077 /* BigInt.swift in Sources */, - BB241C851DDB71920067F917 /* Hashable.swift in Sources */, - BBABCDD31F3E17A8009CA8BC /* Floating Point Conversion.swift in Sources */, - BB241C881DDB71920067F917 /* Subtraction.swift in Sources */, - BB241C8A1DDB71920067F917 /* Division.swift in Sources */, - BB9889AB1F3E5CC600014740 /* Integer Conversion.swift in Sources */, - BB241C831DDB71920067F917 /* BigUInt.swift in Sources */, - BB241C841DDB71920067F917 /* Comparable.swift in Sources */, - BB241C911DDB71920067F917 /* String Conversion.swift in Sources */, - BB241C861DDB71920067F917 /* Data Conversion.swift in Sources */, - BB241C891DDB71920067F917 /* Multiplication.swift in Sources */, - BB9889A61F3E5C3100014740 /* Strideable.swift in Sources */, - BB241C8D1DDB71920067F917 /* Shifts.swift in Sources */, - BB241C8F1DDB71920067F917 /* GCD.swift in Sources */, - BB241C8E1DDB71920067F917 /* Square Root.swift in Sources */, - BBE4CA4F1F3DAD380062A281 /* Codable.swift in Sources */, - BB241C8B1DDB71920067F917 /* Exponentiation.swift in Sources */, - BB241C871DDB71920067F917 /* Addition.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - BBB55AD91C8F88F20050DDA9 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - BB4273F71F24AFCD00065766 /* Tools.swift in Sources */, - BB9916911F33C32000CCFDDC /* WordTests.swift in Sources */, - BB9916901F32610A00CCFDDC /* BigUIntTests.swift in Sources */, - BB99168F1F32610700CCFDDC /* BigIntTests.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - BBB55AEC1C8F8BE00050DDA9 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - BB241C781DDB71910067F917 /* Bitwise Ops.swift in Sources */, - BB241C7E1DDB71910067F917 /* Random.swift in Sources */, - BB241C7C1DDB71910067F917 /* Prime Test.swift in Sources */, - BBABCDD91F3E2038009CA8BC /* Words and Bits.swift in Sources */, - BBC944371F24C25A00ED6C30 /* BigInt.swift in Sources */, - BB241C711DDB71910067F917 /* Hashable.swift in Sources */, - BBABCDD41F3E17A8009CA8BC /* Floating Point Conversion.swift in Sources */, - BB241C741DDB71910067F917 /* Subtraction.swift in Sources */, - BB241C761DDB71910067F917 /* Division.swift in Sources */, - BB9889AC1F3E5CC600014740 /* Integer Conversion.swift in Sources */, - BB241C6F1DDB71910067F917 /* BigUInt.swift in Sources */, - BB241C701DDB71910067F917 /* Comparable.swift in Sources */, - BB241C7D1DDB71910067F917 /* String Conversion.swift in Sources */, - BB241C721DDB71910067F917 /* Data Conversion.swift in Sources */, - BB241C751DDB71910067F917 /* Multiplication.swift in Sources */, - BB9889A71F3E5C3100014740 /* Strideable.swift in Sources */, - BB241C791DDB71910067F917 /* Shifts.swift in Sources */, - BB241C7B1DDB71910067F917 /* GCD.swift in Sources */, - BB241C7A1DDB71910067F917 /* Square Root.swift in Sources */, - BBE4CA501F3DAD390062A281 /* Codable.swift in Sources */, - BB241C771DDB71910067F917 /* Exponentiation.swift in Sources */, - BB241C731DDB71910067F917 /* Addition.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - BBB55AF91C8F8CBB0050DDA9 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - BB241CA01DDB71920067F917 /* Bitwise Ops.swift in Sources */, - BB241CA61DDB71920067F917 /* Random.swift in Sources */, - BB241CA41DDB71920067F917 /* Prime Test.swift in Sources */, - BBABCDDA1F3E2038009CA8BC /* Words and Bits.swift in Sources */, - BBC944381F24C25B00ED6C30 /* BigInt.swift in Sources */, - BB241C991DDB71920067F917 /* Hashable.swift in Sources */, - BBABCDD51F3E17A8009CA8BC /* Floating Point Conversion.swift in Sources */, - BB241C9C1DDB71920067F917 /* Subtraction.swift in Sources */, - BB241C9E1DDB71920067F917 /* Division.swift in Sources */, - BB9889AD1F3E5CC600014740 /* Integer Conversion.swift in Sources */, - BB241C971DDB71920067F917 /* BigUInt.swift in Sources */, - BB241C981DDB71920067F917 /* Comparable.swift in Sources */, - BB241CA51DDB71920067F917 /* String Conversion.swift in Sources */, - BB241C9A1DDB71920067F917 /* Data Conversion.swift in Sources */, - BB241C9D1DDB71920067F917 /* Multiplication.swift in Sources */, - BB9889A81F3E5C3100014740 /* Strideable.swift in Sources */, - BB241CA11DDB71920067F917 /* Shifts.swift in Sources */, - BB241CA31DDB71920067F917 /* GCD.swift in Sources */, - BB241CA21DDB71920067F917 /* Square Root.swift in Sources */, - BBE4CA511F3DAD390062A281 /* Codable.swift in Sources */, - BB241C9F1DDB71920067F917 /* Exponentiation.swift in Sources */, - BB241C9B1DDB71920067F917 /* Addition.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - BBB55B031C8F8CBB0050DDA9 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - BBC9443C1F24C27F00ED6C30 /* BigIntTests.swift in Sources */, - BB241CC51DDB71A60067F917 /* ProfileTests.swift in Sources */, - BB4273F81F24AFCD00065766 /* Tools.swift in Sources */, - BBEAE4DF1F28C37800F4E329 /* WordTests.swift in Sources */, - BB241CDC1DDB79E20067F917 /* BigUIntTests.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXTargetDependency section */ - BB241C611DDB70B00067F917 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = BBB55AD31C8F88F20050DDA9 /* BigInt-macOS */; - targetProxy = BB241C621DDB70B00067F917 /* PBXContainerItemProxy */; - }; - BBB55ABF1C8F80020050DDA9 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = BBB55AB11C8F80020050DDA9 /* BigInt-iOS */; - targetProxy = BBB55ABE1C8F80020050DDA9 /* PBXContainerItemProxy */; - }; - BBB55AE01C8F88F20050DDA9 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = BBB55AD31C8F88F20050DDA9 /* BigInt-macOS */; - targetProxy = BBB55ADF1C8F88F20050DDA9 /* PBXContainerItemProxy */; - }; - BBB55B0A1C8F8CBC0050DDA9 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = BBB55AFD1C8F8CBB0050DDA9 /* BigInt-tvOS */; - targetProxy = BBB55B091C8F8CBC0050DDA9 /* PBXContainerItemProxy */; - }; -/* End PBXTargetDependency section */ - -/* Begin XCBuildConfiguration section */ - BB241C681DDB70B00067F917 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; - APPLICATION_EXTENSION_API_ONLY = NO; - COMBINE_HIDPI_IMAGES = YES; - INFOPLIST_FILE = Tests/BigIntTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "$(BUNDLE_IDENTIFIER_BASE).Tests"; - PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = macosx; - }; - name = Debug; - }; - BB241C691DDB70B00067F917 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; - APPLICATION_EXTENSION_API_ONLY = NO; - COMBINE_HIDPI_IMAGES = YES; - INFOPLIST_FILE = Tests/BigIntTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "$(BUNDLE_IDENTIFIER_BASE).Tests"; - PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = macosx; - }; - name = Release; - }; - BBB55AC41C8F80020050DDA9 /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = BBB55ACC1C8F80660050DDA9 /* version.xcconfig */; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; - CLANG_ANALYZER_NONNULL = YES; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = "$(BUILD_NUMBER)"; - DEBUG_INFORMATION_FORMAT = dwarf; - DYLIB_COMPATIBILITY_VERSION = "$(BUILD_NUMBER)"; - DYLIB_CURRENT_VERSION = "$(BUILD_NUMBER)"; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - MTL_ENABLE_DEBUG_INFO = YES; - ONLY_ACTIVE_ARCH = YES; - OTHER_SWIFT_FLAGS = "-DDebug"; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_SWIFT3_OBJC_INFERENCE = Off; - SWIFT_VERSION = 5.0; - VERSION_INFO_PREFIX = ""; - }; - name = Debug; - }; - BBB55AC51C8F80020050DDA9 /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = BBB55ACC1C8F80660050DDA9 /* version.xcconfig */; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; - CLANG_ANALYZER_NONNULL = YES; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = "$(BUILD_NUMBER)"; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - DYLIB_COMPATIBILITY_VERSION = "$(BUILD_NUMBER)"; - DYLIB_CURRENT_VERSION = "$(BUILD_NUMBER)"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - MTL_ENABLE_DEBUG_INFO = NO; - OTHER_SWIFT_FLAGS = "-DProfile"; - SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_SWIFT3_OBJC_INFERENCE = Off; - SWIFT_VERSION = 5.0; - VALIDATE_PRODUCT = YES; - VERSION_INFO_PREFIX = ""; - }; - name = Release; - }; - BBB55AC71C8F80020050DDA9 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_ENABLE_MODULES = YES; - CODE_SIGN_IDENTITY = ""; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; - DEFINES_MODULE = YES; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - INFOPLIST_FILE = Sources/Info.plist; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "$(BUNDLE_IDENTIFIER_BASE).$(PLATFORM_DISPLAY_NAME:rfc1034identifier)"; - PRODUCT_NAME = "$(PROJECT_NAME)"; - SDKROOT = iphoneos; - SKIP_INSTALL = YES; - SUPPORTS_MACCATALYST = YES; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Debug; - }; - BBB55AC81C8F80020050DDA9 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_ENABLE_MODULES = YES; - CODE_SIGN_IDENTITY = ""; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; - DEFINES_MODULE = YES; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - INFOPLIST_FILE = Sources/Info.plist; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "$(BUNDLE_IDENTIFIER_BASE).$(PLATFORM_DISPLAY_NAME:rfc1034identifier)"; - PRODUCT_NAME = "$(PROJECT_NAME)"; - SDKROOT = iphoneos; - SKIP_INSTALL = YES; - SUPPORTS_MACCATALYST = YES; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Release; - }; - BBB55ACA1C8F80020050DDA9 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; - APPLICATION_EXTENSION_API_ONLY = NO; - INFOPLIST_FILE = Tests/BigIntTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "$(BUNDLE_IDENTIFIER_BASE).Tests"; - PRODUCT_NAME = "$(PROJECT_NAME)-Test"; - SDKROOT = iphoneos; - }; - name = Debug; - }; - BBB55ACB1C8F80020050DDA9 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; - APPLICATION_EXTENSION_API_ONLY = NO; - INFOPLIST_FILE = Tests/BigIntTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "$(BUNDLE_IDENTIFIER_BASE).Tests"; - PRODUCT_NAME = "$(PROJECT_NAME)-Test"; - SDKROOT = iphoneos; - }; - name = Release; - }; - BBB55AE61C8F88F20050DDA9 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_ENABLE_MODULES = YES; - COMBINE_HIDPI_IMAGES = YES; - DEFINES_MODULE = YES; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - FRAMEWORK_VERSION = A; - INFOPLIST_FILE = Sources/Info.plist; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "$(BUNDLE_IDENTIFIER_BASE).$(PLATFORM_DISPLAY_NAME:rfc1034identifier)"; - PRODUCT_NAME = "$(PROJECT_NAME)"; - SDKROOT = macosx; - SKIP_INSTALL = YES; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - }; - name = Debug; - }; - BBB55AE71C8F88F20050DDA9 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_ENABLE_MODULES = YES; - COMBINE_HIDPI_IMAGES = YES; - DEFINES_MODULE = YES; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - FRAMEWORK_VERSION = A; - INFOPLIST_FILE = Sources/Info.plist; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "$(BUNDLE_IDENTIFIER_BASE).$(PLATFORM_DISPLAY_NAME:rfc1034identifier)"; - PRODUCT_NAME = "$(PROJECT_NAME)"; - SDKROOT = macosx; - SKIP_INSTALL = YES; - }; - name = Release; - }; - BBB55AE91C8F88F20050DDA9 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; - APPLICATION_EXTENSION_API_ONLY = NO; - COMBINE_HIDPI_IMAGES = YES; - INFOPLIST_FILE = Tests/BigIntTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "$(BUNDLE_IDENTIFIER_BASE).Tests"; - PRODUCT_NAME = "$(PROJECT_NAME)-Test"; - SDKROOT = macosx; - }; - name = Debug; - }; - BBB55AEA1C8F88F20050DDA9 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; - APPLICATION_EXTENSION_API_ONLY = NO; - COMBINE_HIDPI_IMAGES = YES; - INFOPLIST_FILE = Tests/BigIntTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "$(BUNDLE_IDENTIFIER_BASE).Tests"; - PRODUCT_NAME = "$(PROJECT_NAME)-Test"; - SDKROOT = macosx; - }; - name = Release; - }; - BBB55AF71C8F8BE00050DDA9 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_ENABLE_MODULES = YES; - "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; - DEFINES_MODULE = YES; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - INFOPLIST_FILE = Sources/Info.plist; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "$(BUNDLE_IDENTIFIER_BASE).$(PLATFORM_DISPLAY_NAME:rfc1034identifier)"; - PRODUCT_NAME = "$(PROJECT_NAME)"; - SDKROOT = watchos; - SKIP_INSTALL = YES; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - TARGETED_DEVICE_FAMILY = 4; - }; - name = Debug; - }; - BBB55AF81C8F8BE00050DDA9 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_ENABLE_MODULES = YES; - "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; - DEFINES_MODULE = YES; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - INFOPLIST_FILE = Sources/Info.plist; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "$(BUNDLE_IDENTIFIER_BASE).$(PLATFORM_DISPLAY_NAME:rfc1034identifier)"; - PRODUCT_NAME = "$(PROJECT_NAME)"; - SDKROOT = watchos; - SKIP_INSTALL = YES; - TARGETED_DEVICE_FAMILY = 4; - }; - name = Release; - }; - BBB55B101C8F8CBC0050DDA9 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_ENABLE_MODULES = YES; - "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; - DEFINES_MODULE = YES; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - INFOPLIST_FILE = Sources/Info.plist; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "$(BUNDLE_IDENTIFIER_BASE).$(PLATFORM_DISPLAY_NAME:rfc1034identifier)"; - PRODUCT_NAME = "$(PROJECT_NAME)"; - SDKROOT = appletvos; - SKIP_INSTALL = YES; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - TARGETED_DEVICE_FAMILY = 3; - }; - name = Debug; - }; - BBB55B111C8F8CBC0050DDA9 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_ENABLE_MODULES = YES; - "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; - DEFINES_MODULE = YES; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - INFOPLIST_FILE = Sources/Info.plist; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "$(BUNDLE_IDENTIFIER_BASE).$(PLATFORM_DISPLAY_NAME:rfc1034identifier)"; - PRODUCT_NAME = "$(PROJECT_NAME)"; - SDKROOT = appletvos; - SKIP_INSTALL = YES; - TARGETED_DEVICE_FAMILY = 3; - }; - name = Release; - }; - BBB55B131C8F8CBC0050DDA9 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; - APPLICATION_EXTENSION_API_ONLY = NO; - FRAMEWORK_SEARCH_PATHS = "$(inherited)"; - INFOPLIST_FILE = Tests/BigIntTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "$(BUNDLE_IDENTIFIER_BASE).Tests"; - PRODUCT_NAME = "$(PROJECT_NAME)-Test"; - SDKROOT = appletvos; - }; - name = Debug; - }; - BBB55B141C8F8CBC0050DDA9 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; - APPLICATION_EXTENSION_API_ONLY = NO; - FRAMEWORK_SEARCH_PATHS = "$(inherited)"; - INFOPLIST_FILE = Tests/BigIntTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "$(BUNDLE_IDENTIFIER_BASE).Tests"; - PRODUCT_NAME = "$(PROJECT_NAME)-Test"; - SDKROOT = appletvos; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - BB241C671DDB70B00067F917 /* Build configuration list for PBXNativeTarget "BigInt Benchmark" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - BB241C681DDB70B00067F917 /* Debug */, - BB241C691DDB70B00067F917 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - BBB55AAC1C8F80020050DDA9 /* Build configuration list for PBXProject "BigInt" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - BBB55AC41C8F80020050DDA9 /* Debug */, - BBB55AC51C8F80020050DDA9 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - BBB55AC61C8F80020050DDA9 /* Build configuration list for PBXNativeTarget "BigInt-iOS" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - BBB55AC71C8F80020050DDA9 /* Debug */, - BBB55AC81C8F80020050DDA9 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - BBB55AC91C8F80020050DDA9 /* Build configuration list for PBXNativeTarget "BigInt iOS Tests" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - BBB55ACA1C8F80020050DDA9 /* Debug */, - BBB55ACB1C8F80020050DDA9 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - BBB55AE51C8F88F20050DDA9 /* Build configuration list for PBXNativeTarget "BigInt-macOS" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - BBB55AE61C8F88F20050DDA9 /* Debug */, - BBB55AE71C8F88F20050DDA9 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - BBB55AE81C8F88F20050DDA9 /* Build configuration list for PBXNativeTarget "BigInt macOS Tests" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - BBB55AE91C8F88F20050DDA9 /* Debug */, - BBB55AEA1C8F88F20050DDA9 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - BBB55AF61C8F8BE00050DDA9 /* Build configuration list for PBXNativeTarget "BigInt-watchOS" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - BBB55AF71C8F8BE00050DDA9 /* Debug */, - BBB55AF81C8F8BE00050DDA9 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - BBB55B0F1C8F8CBC0050DDA9 /* Build configuration list for PBXNativeTarget "BigInt-tvOS" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - BBB55B101C8F8CBC0050DDA9 /* Debug */, - BBB55B111C8F8CBC0050DDA9 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - BBB55B121C8F8CBC0050DDA9 /* Build configuration list for PBXNativeTarget "BigInt tvOS Tests" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - BBB55B131C8F8CBC0050DDA9 /* Debug */, - BBB55B141C8F8CBC0050DDA9 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = BBB55AA91C8F80020050DDA9 /* Project object */; -} diff --git a/Carthage/Checkouts/BigInt/BigInt.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Carthage/Checkouts/BigInt/BigInt.xcodeproj/project.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index 0713bb13e..000000000 --- a/Carthage/Checkouts/BigInt/BigInt.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/Carthage/Checkouts/BigInt/BigInt.xcodeproj/xcshareddata/xcbaselines/BB241C601DDB70B00067F917.xcbaseline/3714311D-5102-4569-B213-8DC87DC6C2F3.plist b/Carthage/Checkouts/BigInt/BigInt.xcodeproj/xcshareddata/xcbaselines/BB241C601DDB70B00067F917.xcbaseline/3714311D-5102-4569-B213-8DC87DC6C2F3.plist deleted file mode 100644 index 096fe76f8..000000000 --- a/Carthage/Checkouts/BigInt/BigInt.xcodeproj/xcshareddata/xcbaselines/BB241C601DDB70B00067F917.xcbaseline/3714311D-5102-4569-B213-8DC87DC6C2F3.plist +++ /dev/null @@ -1,92 +0,0 @@ - - - - - classNames - - ProfileTests - - testBalancedMultiplication() - - com.apple.XCTPerformanceMetric_WallClockTime - - baselineAverage - 0.41604 - baselineIntegrationDisplayName - 2016-11-15 18:19:04 - - - testDivision() - - com.apple.XCTPerformanceMetric_WallClockTime - - baselineAverage - 0.70161 - baselineIntegrationDisplayName - 2016-11-15 18:19:04 - - - testFibonacciAddition() - - com.apple.XCTPerformanceMetric_WallClockTime - - baselineAverage - 2.3569 - baselineIntegrationDisplayName - 2016-11-15 18:19:04 - - - testGCD() - - com.apple.XCTPerformanceMetric_WallClockTime - - baselineAverage - 1.801 - baselineIntegrationDisplayName - 2016-11-15 18:19:04 - - - testMersennePrimes() - - com.apple.XCTPerformanceMetric_WallClockTime - - baselineAverage - 4.184 - baselineIntegrationDisplayName - 2016-11-15 18:19:04 - - - testModularExponentiation() - - com.apple.XCTPerformanceMetric_WallClockTime - - baselineAverage - 2.1938 - baselineIntegrationDisplayName - 2016-11-15 18:19:04 - - - testMultiplicationByDigit() - - com.apple.XCTPerformanceMetric_WallClockTime - - baselineAverage - 0.91891 - baselineIntegrationDisplayName - 2016-11-15 18:19:04 - - - testSquareRoot() - - com.apple.XCTPerformanceMetric_WallClockTime - - baselineAverage - 0.48118 - baselineIntegrationDisplayName - 2016-11-15 18:19:04 - - - - - - diff --git a/Carthage/Checkouts/BigInt/BigInt.xcodeproj/xcshareddata/xcbaselines/BB241C601DDB70B00067F917.xcbaseline/3B06D4DF-FC61-43AE-8115-CA5059B5AB1B.plist b/Carthage/Checkouts/BigInt/BigInt.xcodeproj/xcshareddata/xcbaselines/BB241C601DDB70B00067F917.xcbaseline/3B06D4DF-FC61-43AE-8115-CA5059B5AB1B.plist deleted file mode 100644 index d1b347466..000000000 --- a/Carthage/Checkouts/BigInt/BigInt.xcodeproj/xcshareddata/xcbaselines/BB241C601DDB70B00067F917.xcbaseline/3B06D4DF-FC61-43AE-8115-CA5059B5AB1B.plist +++ /dev/null @@ -1,92 +0,0 @@ - - - - - classNames - - ProfileTests - - testBalancedMultiplication() - - com.apple.XCTPerformanceMetric_WallClockTime - - baselineAverage - 0.31603 - baselineIntegrationDisplayName - Jun 21, 2017, 5:03:36 PM - - - testDivision() - - com.apple.XCTPerformanceMetric_WallClockTime - - baselineAverage - 0.60765 - baselineIntegrationDisplayName - Jun 21, 2017, 5:03:36 PM - - - testFibonacciAddition() - - com.apple.XCTPerformanceMetric_WallClockTime - - baselineAverage - 2.0927 - baselineIntegrationDisplayName - Jun 21, 2017, 5:03:36 PM - - - testGCD() - - com.apple.XCTPerformanceMetric_WallClockTime - - baselineAverage - 1.3631 - baselineIntegrationDisplayName - Jun 21, 2017, 5:03:36 PM - - - testMersennePrimes() - - com.apple.XCTPerformanceMetric_WallClockTime - - baselineAverage - 3.4959 - baselineIntegrationDisplayName - Jun 21, 2017, 5:03:36 PM - - - testModularExponentiation() - - com.apple.XCTPerformanceMetric_WallClockTime - - baselineAverage - 1.7139 - baselineIntegrationDisplayName - Jun 21, 2017, 5:03:36 PM - - - testMultiplicationByDigit() - - com.apple.XCTPerformanceMetric_WallClockTime - - baselineAverage - 0.60397 - baselineIntegrationDisplayName - Jun 21, 2017, 5:03:36 PM - - - testSquareRoot() - - com.apple.XCTPerformanceMetric_WallClockTime - - baselineAverage - 0.40256 - baselineIntegrationDisplayName - Jun 21, 2017, 5:03:36 PM - - - - - - diff --git a/Carthage/Checkouts/BigInt/BigInt.xcodeproj/xcshareddata/xcbaselines/BB241C601DDB70B00067F917.xcbaseline/E75E9014-DB8C-4424-B05B-83660CCFB7ED.plist b/Carthage/Checkouts/BigInt/BigInt.xcodeproj/xcshareddata/xcbaselines/BB241C601DDB70B00067F917.xcbaseline/E75E9014-DB8C-4424-B05B-83660CCFB7ED.plist deleted file mode 100644 index bf59955f7..000000000 --- a/Carthage/Checkouts/BigInt/BigInt.xcodeproj/xcshareddata/xcbaselines/BB241C601DDB70B00067F917.xcbaseline/E75E9014-DB8C-4424-B05B-83660CCFB7ED.plist +++ /dev/null @@ -1,122 +0,0 @@ - - - - - classNames - - ProfileTests - - testBalancedFactorial() - - com.apple.XCTPerformanceMetric_WallClockTime - - baselineAverage - 0.33337 - baselineIntegrationDisplayName - Jul 23, 2017, 12:47:59 - - - testDivision() - - com.apple.XCTPerformanceMetric_WallClockTime - - baselineAverage - 0.59507 - baselineIntegrationDisplayName - Jul 23, 2017, 12:47:59 - - - testDivisionOfFactorial() - - com.apple.XCTPerformanceMetric_WallClockTime - - baselineAverage - 3.6987 - baselineIntegrationDisplayName - Jul 23, 2017, 12:47:59 - - - testFactorial() - - com.apple.XCTPerformanceMetric_WallClockTime - - baselineAverage - 0.66551 - baselineIntegrationDisplayName - Jul 23, 2017, 12:47:59 - - - testFibonacciAddition() - - com.apple.XCTPerformanceMetric_WallClockTime - - baselineAverage - 2.0881 - baselineIntegrationDisplayName - Jul 23, 2017, 12:47:59 - - - testGCD() - - com.apple.XCTPerformanceMetric_WallClockTime - - baselineAverage - 1.3696 - baselineIntegrationDisplayName - Jul 23, 2017, 12:47:59 - - - testMersennePrimes() - - com.apple.XCTPerformanceMetric_WallClockTime - - baselineAverage - 3.71 - baselineIntegrationDisplayName - Jul 23, 2017, 12:47:59 - - - testModularExponentiation() - - com.apple.XCTPerformanceMetric_WallClockTime - - baselineAverage - 1.8318 - baselineIntegrationDisplayName - Jul 23, 2017, 12:47:59 - - - testPrintingFactorial() - - com.apple.XCTPerformanceMetric_WallClockTime - - baselineAverage - 0.95106 - baselineIntegrationDisplayName - Jul 23, 2017, 12:47:59 - - - testReadingFactorial() - - com.apple.XCTPerformanceMetric_WallClockTime - - baselineAverage - 0.48879 - baselineIntegrationDisplayName - Jul 23, 2017, 12:47:59 - - - testSquareRoot() - - com.apple.XCTPerformanceMetric_WallClockTime - - baselineAverage - 0.45393 - baselineIntegrationDisplayName - Jul 23, 2017, 12:47:59 - - - - - - diff --git a/Carthage/Checkouts/BigInt/BigInt.xcodeproj/xcshareddata/xcbaselines/BB241C601DDB70B00067F917.xcbaseline/Info.plist b/Carthage/Checkouts/BigInt/BigInt.xcodeproj/xcshareddata/xcbaselines/BB241C601DDB70B00067F917.xcbaseline/Info.plist deleted file mode 100644 index 3d624f11a..000000000 --- a/Carthage/Checkouts/BigInt/BigInt.xcodeproj/xcshareddata/xcbaselines/BB241C601DDB70B00067F917.xcbaseline/Info.plist +++ /dev/null @@ -1,57 +0,0 @@ - - - - - runDestinationsByUUID - - 3714311D-5102-4569-B213-8DC87DC6C2F3 - - localComputer - - busSpeedInMHz - 100 - cpuCount - 1 - cpuKind - Intel Core i7 - cpuSpeedInMHz - 2600 - logicalCPUCoresPerPackage - 8 - modelCode - MacBookPro10,1 - physicalCPUCoresPerPackage - 4 - platformIdentifier - com.apple.platform.macosx - - targetArchitecture - x86_64 - - E75E9014-DB8C-4424-B05B-83660CCFB7ED - - localComputer - - busSpeedInMHz - 100 - cpuCount - 1 - cpuKind - Intel Core i7 - cpuSpeedInMHz - 2900 - logicalCPUCoresPerPackage - 8 - modelCode - MacBookPro14,3 - physicalCPUCoresPerPackage - 4 - platformIdentifier - com.apple.platform.macosx - - targetArchitecture - x86_64 - - - - diff --git a/Carthage/Checkouts/BigInt/BigInt.xcodeproj/xcshareddata/xcschemes/BigInt Benchmark.xcscheme b/Carthage/Checkouts/BigInt/BigInt.xcodeproj/xcshareddata/xcschemes/BigInt Benchmark.xcscheme deleted file mode 100644 index ee198da4d..000000000 --- a/Carthage/Checkouts/BigInt/BigInt.xcodeproj/xcshareddata/xcschemes/BigInt Benchmark.xcscheme +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/Carthage/Checkouts/BigInt/BigInt.xcodeproj/xcshareddata/xcschemes/BigInt-iOS.xcscheme b/Carthage/Checkouts/BigInt/BigInt.xcodeproj/xcshareddata/xcschemes/BigInt-iOS.xcscheme deleted file mode 100644 index be801d122..000000000 --- a/Carthage/Checkouts/BigInt/BigInt.xcodeproj/xcshareddata/xcschemes/BigInt-iOS.xcscheme +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Carthage/Checkouts/BigInt/BigInt.xcodeproj/xcshareddata/xcschemes/BigInt-macOS.xcscheme b/Carthage/Checkouts/BigInt/BigInt.xcodeproj/xcshareddata/xcschemes/BigInt-macOS.xcscheme deleted file mode 100644 index b7ffe245b..000000000 --- a/Carthage/Checkouts/BigInt/BigInt.xcodeproj/xcshareddata/xcschemes/BigInt-macOS.xcscheme +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Carthage/Checkouts/BigInt/BigInt.xcodeproj/xcshareddata/xcschemes/BigInt-tvOS.xcscheme b/Carthage/Checkouts/BigInt/BigInt.xcodeproj/xcshareddata/xcschemes/BigInt-tvOS.xcscheme deleted file mode 100644 index a5bc818f2..000000000 --- a/Carthage/Checkouts/BigInt/BigInt.xcodeproj/xcshareddata/xcschemes/BigInt-tvOS.xcscheme +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Carthage/Checkouts/BigInt/BigInt.xcodeproj/xcshareddata/xcschemes/BigInt-watchOS.xcscheme b/Carthage/Checkouts/BigInt/BigInt.xcodeproj/xcshareddata/xcschemes/BigInt-watchOS.xcscheme deleted file mode 100644 index a684b0058..000000000 --- a/Carthage/Checkouts/BigInt/BigInt.xcodeproj/xcshareddata/xcschemes/BigInt-watchOS.xcscheme +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Carthage/Checkouts/BigInt/BigInt.xcworkspace/contents.xcworkspacedata b/Carthage/Checkouts/BigInt/BigInt.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index 8fad35107..000000000 --- a/Carthage/Checkouts/BigInt/BigInt.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/Carthage/Checkouts/BigInt/BigInt.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Carthage/Checkouts/BigInt/BigInt.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist deleted file mode 100644 index 18d981003..000000000 --- a/Carthage/Checkouts/BigInt/BigInt.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +++ /dev/null @@ -1,8 +0,0 @@ - - - - - IDEDidComputeMac32BitWarning - - - diff --git a/Carthage/Checkouts/BigInt/CHANGELOG.md b/Carthage/Checkouts/BigInt/CHANGELOG.md deleted file mode 100644 index bd418d48e..000000000 --- a/Carthage/Checkouts/BigInt/CHANGELOG.md +++ /dev/null @@ -1,218 +0,0 @@ -# 5.2.0 (2020-08-24) - -This release contains the following changes: - -- Added support for the use of RandomNumberGenerator - -# 5.1.0 (2020-03-17) - -This release contains the following changes: - -- Added support to serialize/deserialize BigInt in a manner similar to BigUInt - -# 5.0.0 (2019-08-24) - -This release contains the following changes: - -- Swift 5 compatibility - -There were no functional changes. - -# 4.0.1 (2019-05-09) - -This release contains the following changes: - -- Cleaned warnings on Swift 5 - -There were no functional changes. - -# 4.0.0 (2019-04-03) - -This release contains the following changes: - -- Swift 5.0 compatibility for Linux and macOS -- Removed SipHash dependency - -There were no functional changes. - -# 3.1.0 (2018-06-08) - -This release contains the following changes: - -- Swift 4.1 compatibility for Linux and macOS -- Fix warnings for Swift 4.1 - -There were no functional changes. - -# 3.0.2 (2017-12-25) - -This release contains the following packaging fix: - -- Fixed product definitions in Package.swift not to create a duplicate library. (Issue #37) - -There were no functional changes. - -# 3.0.1 (2017-10-10) - -This release contains the following bug fixes: - -- Issue #27 — changing scope of `BigUInt` methods `kind` and `storage` to be `fileprivate` -- Making `subscript` method of `BigUInt` public - -# 3.0.0 (2017-09-07) - -This is a major release upgrading BigInt to the new integer protocols introduced in Swift 4 as part of [SE-0104, Protocol-oriented integers][se-0104]. - -[se-0104]: https://github.com/apple/swift-evolution/blob/master/proposals/0104-improved-integers.md - -- Adopting the new protocols involved major, breaking changes throughout the API. These aren't individually listed here. -- The `BigUInt` struct now provides inline storage for big integers that fit inside two words. This optimization speeds up conversions from built-in fixed-width integer types, amongst other frequent operations. -- `BigInt` and `BigUInt` implements the new `Codable` protocol. In both cases, values are encoded in an unkeyed container starting with a string indicating the sign (`"+"` or `"-"`), followed by a sequence of 64-bit unsigned integers representing component words, from least to most significant. -- New method: `BigInt.modulo`, contributed by @FabioTacke. -- `BigUInt` does not implement `Collection` in this release. The collection of words is available in the standard read-only `words` property. Direct public access to collection methods have been removed; if you have been manipulating big integers using collection methods, you need to rewrite your code. If you have a usecase that isn't covered by the public API, please submit a PR adding the missing functionality. (Public read-write access to the underlying storage inside `BigUInt` will not be restored, though.) - -BigInt is now part of the Attaswift project. The bundle identifiers in the supplied Xcode project have been updated accordingly. - -Note that the URL for the package's Git repository has changed; please update your references. - -# 2.2.0 (2017-06-20) - -This release contains the following changes: - -- `BigUInt.randomIntegerLessThan(_:)` was renamed to `BigUInt.randomInteger(lessThan:)` to match Swift 3 naming conventions. (The old name is still available for compatibility.) -- The `ShiftOperations` protocol was merged into `BigDigit` and removed. It was previously public by accident. (Issue #9) -- `BigInt.modulus(_:,_:)` is a new static method that returns the nonnegative modulus value of its two arguments. (PR #19 by @FabioTacke) - - -# 2.1.2 (2017-02-03) - -This release contains the following bugfix: - -- Issue #12: The iOS target in the supplied Xcode project file no longer copies extraneous files - as resources into the framework bundle. The set of such files included generate-docs.sh, which - led to App Store rejections for apps that build BigInt using the project file. - (Thanks to @arrrnas and @wuftymerguftyguff) - -No source-level changes were made. - -# 2.1.1 (2016-11-23) - -This release restores support for iOS 8.0 and macOS 10.9. - -# 2.1.0 (2016-11-15) - -This release contains the following changes: - -- BigInt now uses the SipHash hashing algorithm instead of implementing its own hashing. -- The `SipHash` package has been added as a required dependency. I suggest you use a dependency manager. -- Minimum deployment targets have been bumped to iOS 9.0 and macOS 10.0 to match those of `SipHash`. -- BigInt now requires Swift 3.0.1, included in Xcode 8.1. -- The Xcode project file has been regenerated from scratch, with new names for targets and schemes. -- The bundle identifiers of frameworks generated from the Xcode project file have been changed to `hu.lorentey.BigInt.`. - -# 2.0.1 (2016-11-08) - -This release contains the following bugfixes: - -- The Swift version number is now correctly set in all targets (PR #7 by @mAu888). -- BigInt now builds on Linux (PR #5 by @ratranqu). -- Building BigInt with the Swift Package Manager bundled with Swift 3.0.1 works correctly. - -Additionally, Foundation imports that weren't actually needed were removed from sources. - -# 2.0.0 (2016-09-20) - -This release updates the project for Swift 3.0, including adapting the API to the new naming conventions. - -Further changes: - -- The behavior of `BigUInt.gcd` when one of the arguments is zero has been fixed; the result in this case is now equal to the other argument. -- `BigInt` now conforms to `Strideable`, `IntegerArithmetic`, `SignedNumber` and `AbsoluteValuable`. -- `BigUInt` now conforms to `Strideable`, `IntegerArithmetic` and `BitwiseOperations`. - -# 1.3.0 (2016-03-23) - -This release updates the project to require Swift 2.2 and Xcode 7.3. There have been no other changes. - -# 1.2.3 (2016-01-12) - -This release adds experimental support for the Swift Package Manager and Swift 2.2. -There were no source-level changes. - -# 1.2.2 (2016-01-08) - -This release fixes version numbers embedded in build products. - -# 1.2.1 (2016-01-07) - -This release simply removes the stray LICENSE.md file from iOS builds. - - -# 1.2.0 (2016-01-06) - -With this release, BigInt supports watchOS and tvOS in addition to OS X and iOS. Deployment targets are as follows: - -- OS X 10.9 -- iOS 8 -- watchOS 2 -- tvOS 9 - -BigInt 1.2.0 also features support for both Carthage and CocoaPods deployments. - - -# 1.1.0 (2016-01-06) - -`BigInt` now contains enough functionality to pretend it's a respectable big integer lib. Some of the new additions since 1.0.0: - -- Conversion to/from `NSData` -- Vanilla exponentiation -- Algorithm to find the multiplicative inverse of an integer in modulo arithmetic -- An implementation of the Miller-Rabin primality test -- Support for generating random big integers -- Better support for playgrounds in Xcode -- Documentation for all public API -- Fun new calculation samples - - -# 1.0.0 (2016-01-04) - -This is the first release of the BigInt module, providing arbitrary precision integer arithmetic operations -in pure Swift. - -Two big integer types are included: `BigUInt` and `BigInt`, the latter being the signed variant. -Both of these are Swift structs with copy-on-write value semantics, and they can be used much -like any other integer type. - -The library provides implementations for some of the most frequently useful functions on -big integers, including - -- All functionality from `Comparable` and `Hashable` -- The full set of arithmetic operators: `+`, `-`, `*`, `/`, `%`, `+=`, `-=`, `*=`, `/=`, `%=` -- Addition and subtraction have variants that allow for shifting the digits of the second -operand on the fly. -- Unsigned subtraction will trap when the result would be negative. (There are variants -that return an overflow flag.) -- Multiplication uses brute force for numbers up to 1024 digits, then switches to Karatsuba's recursive method. -(This limit is configurable, see `BigUInt.directMultiplicationLimit`.) -A fused multiply-add method is also available. -- Division uses Knuth's Algorithm D, with its 3/2 digits wide quotient approximation. -It will trap when the divisor is zero. `BigUInt.divmod` returns the quotient and -remainder at once; this is faster than calculating them separately. -- Bitwise operators: `~`, `|`, `&`, `^`, `|=`, `&=`, `^=`, plus the following read-only properties: -- `width`: the minimum number of bits required to store the integer, -- `trailingZeroBitCount`: the number of trailing zero bits in the binary representation, -- `leadingZeroBitCount`: the number of leading zero bits (when the last digit isn't full), -- Shift operators: `>>`, `<<`, `>>=`, `<<=` -- Left shifts need to allocate memory to extend the digit array, so it's probably not a good idea -to left shift a `BigUInt` by 2^50 bits. -- Radix conversion between `String`s and big integers up to base 36 (using repeated divisions). -- Big integers use this to implement `StringLiteralConvertible` (in base 10). -- `sqrt(n)`: The square root of an integer (using Newton's method) -- `BigUInt.gcd(n, m)`: The greatest common divisor of two integers (Stein's algorithm) -- `BigUInt.powmod(base, exponent, modulus)`: Modular exponentiation (right-to-left binary method): - -The implementations are intended to be reasonably efficient, but they are unlikely to be -competitive with GMP at all, even when I happened to implement an algorithm with same asymptotic -behavior as GMP. (I haven't performed a comparison benchmark, though.) - -The library has 100% unit test coverage. diff --git a/Carthage/Checkouts/BigInt/Demo.playground/Pages/Digits of Pi.xcplaygroundpage/Contents.swift b/Carthage/Checkouts/BigInt/Demo.playground/Pages/Digits of Pi.xcplaygroundpage/Contents.swift deleted file mode 100644 index 092120fe7..000000000 --- a/Carthage/Checkouts/BigInt/Demo.playground/Pages/Digits of Pi.xcplaygroundpage/Contents.swift +++ /dev/null @@ -1,28 +0,0 @@ -//: [Previous](@previous) -import BigInt -//: ## Let's calculate the first thousand digits of π -//: -//: A fun application of BigInts is generating the digits of π. -//: Let's implement [Jeremy Gibbon's spigot algorithm][spigot] as an infinite `GeneratorType`. -//: This is a quite slow algorithm, but it makes up for it with its grooviness factor. -//: -//: [spigot]: http://www.cs.ox.ac.uk/jeremy.gibbons/publications/spigot.pdf -func digitsOfPi() -> AnyIterator { - var q: BigUInt = 1 - var r: BigUInt = 180 - var t: BigUInt = 60 - var i: UInt = 2 // Works until digit #826_566_842 - return AnyIterator { - let u: UInt = 3 * (3 * i + 1) * (3 * i + 2) - let y = (q.multiplied(byWord: 27 * i - 12) + 5 * r) / (5 * t) - (q, r, t) = ( - 10 * q.multiplied(byWord: i * (2 * i - 1)), - 10 * (q.multiplied(byWord: 5 * i - 2) + r - y * t).multiplied(byWord: u), - t.multiplied(byWord: u)) - i += 1 - return Int(y.words[0]) - } -} -//: Well, that was surprisingly easy. Does it work? You bet: -let digits = digitsOfPi().prefix(999).reduce("") { $0 + String($1) } -//: [Next](@next) diff --git a/Carthage/Checkouts/BigInt/Demo.playground/Pages/Factorials.xcplaygroundpage/Contents.swift b/Carthage/Checkouts/BigInt/Demo.playground/Pages/Factorials.xcplaygroundpage/Contents.swift deleted file mode 100644 index 24e7992b3..000000000 --- a/Carthage/Checkouts/BigInt/Demo.playground/Pages/Factorials.xcplaygroundpage/Contents.swift +++ /dev/null @@ -1,30 +0,0 @@ -//: [Previous](@previous) -import Foundation -import BigInt -//: The canonical way to demo big integers is with the factorial function. Here is a fancy definition for it: -func fact(_ n: Int) -> BigInt { - return (1 ... n).map { BigInt($0) }.reduce(BigInt(1), *) -} - -let f1 = fact(1) -let f2 = fact(2) -let f3 = fact(3) -let f4 = fact(4) -let f10 = fact(10) -let f100 = fact(100) -let f1000 = fact(1000) -//: That last value seems quite large. Just how many decimal digits is it? Let's convert it to a `String` to find out. -let decimal = String(f1000) -let digitCount = decimal.characters.count -//: Wow. 2500 digits is peanuts for `BigInt`, but Xcode's playground tech isn't designed to perform well with much more loop iterations, so let's stay at this level for now. -let ff2 = f1000 * f1000 -String(ff2).characters.count - -let ff4 = ff2 * ff2 -String(ff4).characters.count - -let ff8 = ff4 * ff4 -String(ff8).characters.count -//: That last operation multiplied two 10000-digit numbers; you may have noticed it took a couple of seconds to compute that value. Converting such huge values to decimal isn't particularly cheap, either. -//: -//: [Next](@next) diff --git a/Carthage/Checkouts/BigInt/Demo.playground/Pages/Generating Large Primes.xcplaygroundpage/Contents.swift b/Carthage/Checkouts/BigInt/Demo.playground/Pages/Generating Large Primes.xcplaygroundpage/Contents.swift deleted file mode 100644 index bc08ca525..000000000 --- a/Carthage/Checkouts/BigInt/Demo.playground/Pages/Generating Large Primes.xcplaygroundpage/Contents.swift +++ /dev/null @@ -1,25 +0,0 @@ -//: [Previous](@previous) -import Foundation -import BigInt -//: # Generating Large Prime Numbers -//: -//: `BigUInt` has an `isPrime()` method that does a [Miller-Rabin Primality Test][mrpt]. Let's use -//: this to create a function that finds the next prime number after any integer: -//: -//: [mrpt]: https://en.wikipedia.org/wiki/Miller%2dRabin_primality_test -func findNextPrime(after integer: BigUInt) -> BigUInt { - var candidate = integer - repeat { - candidate.increment() - } while !candidate.isPrime() - return candidate -} - -findNextPrime(after: 100) -findNextPrime(after: 1000) -findNextPrime(after: 10000) -findNextPrime(after: 100000000000) -findNextPrime(after: BigUInt(1) << 64) -findNextPrime(after: BigUInt(1) << 128) -findNextPrime(after: BigUInt(1) << 256) -//: [Next](@next) diff --git a/Carthage/Checkouts/BigInt/Demo.playground/Pages/Introduction.xcplaygroundpage/Contents.swift b/Carthage/Checkouts/BigInt/Demo.playground/Pages/Introduction.xcplaygroundpage/Contents.swift deleted file mode 100644 index 375a30581..000000000 --- a/Carthage/Checkouts/BigInt/Demo.playground/Pages/Introduction.xcplaygroundpage/Contents.swift +++ /dev/null @@ -1,31 +0,0 @@ -//: # Introduction -//: -//: The `BigInt` module provides a `BigInt` type that implements an [https://en.wikipedia.org/wiki/Arbitrary-precision_arithmetic](integer type of arbitrary width). -//: These work much like `Int`s, but they don't have a preset maximum value---so they will never overflow. -//: The only practical limit to their capacity is the amount of memory & address space that your computer has, and the -//: amount of time you're willing to spend waiting for results---when their operands are truly huge, -//: big integer operations can take a long time to execute. -//: (`BigInt` represents integers in base 2^64, storing digits in an `Array`, so the theoretical -//: maximum value it can store is (2^64)^`Int.max` - 1.) -import Foundation -import BigInt -//: `BigInt` has several interesting initializers, but for now, the simplest way to create big integers is to use integer -//: or string literals. The latter is useful when you want to create a number that's larger than `UIntMax.max`: -let a: BigInt = 123 -let b: BigInt = 12345678 -let c: BigInt = 1234567890123456 -let d: BigInt = "12345678901234567890123456789012345678901234567890123456789012345678" -//: To work with `BigInt`s, you use the same arithmetic operators as you do with everyday `Int` values: -a + b -b - a --b -a * b -a * b * c -a * b * c * d - -d / c -d % c -d / (c * c) -d / (c * c * c) -d / (c * c * c * c) -//: [Next](@next) diff --git a/Carthage/Checkouts/BigInt/Demo.playground/Pages/The RSA algorithm.xcplaygroundpage/Contents.swift b/Carthage/Checkouts/BigInt/Demo.playground/Pages/The RSA algorithm.xcplaygroundpage/Contents.swift deleted file mode 100644 index 43e759411..000000000 --- a/Carthage/Checkouts/BigInt/Demo.playground/Pages/The RSA algorithm.xcplaygroundpage/Contents.swift +++ /dev/null @@ -1,57 +0,0 @@ -//: [Previous](@previous) -import Foundation -import BigInt -//: # RSA cryptography -//: -//: Another useful thing to have is a function that finds a random n-bit prime number: -func generatePrime(ofWidth width: Int) -> BigUInt { - while true { - var random = BigUInt.randomInteger(withExactWidth: width) - random |= BigUInt(1) - if random.isPrime() { - return random - } - } -} -//: For instance, here are two random 1024-bit prime numbers: -let p = generatePrime(ofWidth: 1024) -let q = generatePrime(ofWidth: 1024) -//: We know their product isn't prime, and `BigInt`'s primality test agrees: -let n = p * q -n.isPrime() -//: But we'd be in serious trouble if we had to get `p` and `q` back by factoring `n`---and this observation is -//: what makes RSA work. -//: -//: So let's derive a public/private RSA keypair out of these two primes: -//: -//: (Note though that in a real RSA cryptosystem, primes are chosen much more carefully.) -let phi = (p - 1) * (q - 1) -let e: BigUInt = 65537 -let d = e.inverse(phi)! - -d * e % phi - -typealias Key = (modulus: BigUInt, exponent: BigUInt) - -let publicKey: Key = (n, e) -let privateKey: Key = (n, d) -//: Given a key and a message, encryption is simply a modular exponentiation: -//: (Again, this is an oversimplification. In the real RSA system, the message is first transformed by a -//: [complex padding scheme][oaep].) -//: -//: [oaep]: https://en.wikipedia.org/wiki/Optimal_asymmetric_encryption_padding -func encrypt(_ message: BigUInt, key: Key) -> BigUInt { - return message.power(key.exponent, modulus: key.modulus) -} -//: Let's try encrypting some message with the public key. -let secret: BigUInt = BigUInt("Arbitrary precision arithmetic is fun!".data(using: .utf8)!) - -let cyphertext = encrypt(secret, key: publicKey) -//: Well that was easy. In theory, we can decrypt the cyphertext by simply encrypting it with the private key. -//: But does it really work? Yep: -let plaintext = encrypt(cyphertext, key: privateKey) - -let message = String(data: plaintext.serialize(), encoding: .utf8) -//: Isn't that awesome? -//: -//: [Next](@next) diff --git a/Carthage/Checkouts/BigInt/Demo.playground/contents.xcplayground b/Carthage/Checkouts/BigInt/Demo.playground/contents.xcplayground deleted file mode 100644 index 5a1e6af0e..000000000 --- a/Carthage/Checkouts/BigInt/Demo.playground/contents.xcplayground +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/Carthage/Checkouts/BigInt/LICENSE.md b/Carthage/Checkouts/BigInt/LICENSE.md deleted file mode 100644 index 18cefd118..000000000 --- a/Carthage/Checkouts/BigInt/LICENSE.md +++ /dev/null @@ -1,20 +0,0 @@ - -Copyright (c) 2016-2017 Károly Lőrentey - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/Carthage/Checkouts/BigInt/LinuxMain.swift b/Carthage/Checkouts/BigInt/LinuxMain.swift deleted file mode 100644 index 1d6ba3763..000000000 --- a/Carthage/Checkouts/BigInt/LinuxMain.swift +++ /dev/null @@ -1,7 +0,0 @@ -import XCTest -@testable import BigIntTests - -XCTMain([ - testCase(BigIntTests.allTests), - testCase(BigUIntTests.allTests), -]) diff --git a/Carthage/Checkouts/BigInt/Package.swift b/Carthage/Checkouts/BigInt/Package.swift deleted file mode 100644 index 7bc0b9771..000000000 --- a/Carthage/Checkouts/BigInt/Package.swift +++ /dev/null @@ -1,21 +0,0 @@ -// swift-tools-version:5.0 -// -// Package.swift -// BigInt -// -// Created by Károly Lőrentey on 2016-01-12. -// Copyright © 2016-2017 Károly Lőrentey. -// - -import PackageDescription - -let package = Package( - name: "BigInt", - products: [ - .library(name: "BigInt", targets: ["BigInt"]) - ], - targets: [ - .target(name: "BigInt", path: "Sources"), - .testTarget(name: "BigIntTests", dependencies: ["BigInt"], path: "Tests") - ] -) diff --git a/Carthage/Checkouts/BigInt/README.md b/Carthage/Checkouts/BigInt/README.md deleted file mode 100644 index 2256249cd..000000000 --- a/Carthage/Checkouts/BigInt/README.md +++ /dev/null @@ -1,430 +0,0 @@ -[![BigInt](https://github.com/attaswift/BigInt/raw/master/images/banner.png)](https://github.com/attaswift/BigInt) - -* [Overview](#overview) -* [API Documentation](#api) -* [License](#license) -* [Requirements and Integration](#integration) -* [Implementation Notes](#notes) - * [Full-width multiplication and division primitives](#fullwidth) - * [Why is there no generic `BigInt` type?](#generics) -* [Calculation Samples](#samples) - * [Obligatory factorial demo](#factorial) - * [RSA Cryptography](#rsa) - * [Calculating the Digits of π](#pi) - -[![Swift 3](https://img.shields.io/badge/Swift-5-blue.svg)](https://developer.apple.com/swift/) -[![License](https://img.shields.io/badge/licence-MIT-blue.svg)](http://cocoapods.org/pods/BigInt) -[![Platform](https://img.shields.io/cocoapods/p/BigInt.svg)](http://cocoapods.org/pods/BigInt) - -[![Build Status](https://travis-ci.org/attaswift/BigInt.svg?branch=master)](https://travis-ci.org/attaswift/BigInt) -[![Code Coverage](https://codecov.io/github/attaswift/BigInt/coverage.svg?branch=master)](https://codecov.io/github/attaswift/BigInt?branch=master) -[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg)](https://github.com/Carthage/Carthage) -[![Version](https://img.shields.io/cocoapods/v/BigInt.svg)](http://cocoapods.org/pods/BigInt) - -## Overview - -This repository provides [integer types of arbitrary width][wiki] implemented -in 100% pure Swift. The underlying representation is in base 2^64, using `Array`. - -[wiki]: https://en.wikipedia.org/wiki/Arbitrary-precision_arithmetic - -This module is handy when you need an integer type that's wider than `UIntMax`, but -you don't want to add [The GNU Multiple Precision Arithmetic Library][GMP] -as a dependency. - -[GMP]: https://gmplib.org - -Two big integer types are included: [`BigUInt`][BigUInt] and [`BigInt`][BigInt], -the latter being the signed variant. -Both of these are Swift structs with copy-on-write value semantics, and they can be used much -like any other integer type. - -The library provides implementations for some of the most frequently useful functions on -big integers, including - -- All functionality from [`Comparable`][comparison] and [`Hashable`][hashing] - -- [The full set of arithmetic operators][addition]: `+`, `-`, `*`, `/`, `%`, `+=`, `-=`, `*=`, `/=`, `%=` - - [Addition][addition] and [subtraction][subtraction] have variants that allow for - shifting the digits of the second operand on the fly. - - Unsigned subtraction will trap when the result would be negative. - ([There are variants][subtraction] that return an overflow flag.) - - [Multiplication][mul] uses brute force for numbers up to 1024 digits, then switches to Karatsuba's recursive method. - (This limit is configurable, see `BigUInt.directMultiplicationLimit`.) - - A [fused multiply-add][fused] method is also available, along with other [special-case variants][multiplication]. - - [Division][division] uses Knuth's Algorithm D, with its 3/2 digits wide quotient approximation. - It will trap when the divisor is zero. - - [`BigUInt.divide`][divide] returns the quotient and - remainder at once; this is faster than calculating them separately. - -- [Bitwise operators][bitwise]: `~`, `|`, `&`, `^`, `|=`, `&=`, `^=`, plus the following read-only properties: - - [`width`][width]: the minimum number of bits required to store the integer, - - [`trailingZeroBitCount`][trailingZeroBitCount]: the number of trailing zero bits in the binary representation, - - [`leadingZeroBitCount`][leadingZeroBitCount]: the number of leading zero bits (when the last digit isn't full), - -- [Shift operators][shift]: `>>`, `<<`, `>>=`, `<<=` - -- Methods to [convert `NSData` to big integers][data] and vice versa. - -- Support for [generating random integers][random] of specified maximum width or magnitude. - -- Radix conversion to/from [`String`s][radix1] and [big integers][radix2] up to base 36 (using repeated divisions). - - Big integers use this to implement `StringLiteralConvertible` (in base 10). - -- [`sqrt(n)`][sqrt]: The square root of an integer (using Newton's method). - -- [`BigUInt.gcd(n, m)`][GCD]: The greatest common divisor of two integers (Stein's algorithm). - -- [`base.power(exponent, modulus)`][powmod]: Modular exponentiation (right-to-left binary method). - [Vanilla exponentiation][power] is also available. -- [`n.inverse(modulus)`][inverse]: Multiplicative inverse in modulo arithmetic (extended Euclidean algorithm). -- [`n.isPrime()`][prime]: Miller–Rabin primality test. - -The implementations are intended to be reasonably efficient, but they are unlikely to be -competitive with GMP at all, even when I happened to implement an algorithm with same asymptotic -behavior as GMP. (I haven't performed a comparison benchmark, though.) - -The library has 100% unit test coverage. Sadly this does not imply that there are no bugs -in it. - -## API Documentation - -Generated API docs are available at http://attaswift.github.io/BigInt/. - -## License - -BigInt can be used, distributed and modified under [the MIT license][license]. - -## Requirements and Integration - -BigInt 4.0.0 requires Swift 4.2 (The last version with support for Swift 3.x was BigInt 2.1.0. -The last version with support for Swift 2 was BigInt 1.3.0.) - -| Swift Version | last BigInt Version| -| ------------- |:-------------------| -| 3.x | 2.1.0 | -| 4.0 | 3.1.0 | -| 4.2 | 4.0.0 | -| 5.0 | 5.0.0 | - -BigInt deploys to macOS 10.10, iOS 9, watchOS 2 and tvOS 9. -It has been tested on the latest OS releases only---however, as the module uses very few platform-provided APIs, -there should be very few issues with earlier versions. - -BigInt uses no APIs specific to Apple platforms, so -it should be easy to port it to other operating systems. - -Setup instructions: - -- **Swift Package Manager:** - Although the Package Manager is still in its infancy, BigInt provides experimental support for it. - Add this to the dependency section of your `Package.swift` manifest: - - ```Swift - .package(url: "https://github.com/attaswift/BigInt.git", from: "5.0.0") - ``` - -- **CocoaPods:** Put this in your `Podfile`: - - ```Ruby - pod 'BigInt', '~> 5.0' - ``` - -- **Carthage:** Put this in your `Cartfile`: - - ``` - github "attaswift/BigInt" ~> 5.0 - ``` - -## Implementation notes - -[`BigUInt`][BigUInt] is a `MutableCollectionType` of its 64-bit digits, with the least significant -digit at index 0. As a convenience, [`BigUInt`][BigUInt] allows you to subscript it with indexes at -or above its `count`. [The subscript operator][subscript] returns 0 for out-of-bound `get`s and -automatically extends the array on out-of-bound `set`s. This makes memory management simpler. - -[`BigInt`][BigInt] is just a tiny wrapper around a `BigUInt` [absolute value][abs] and a -[sign bit][negative], both of which are accessible as public read-write properties. - -### Why is there no generic `BigInt` type? - -The types provided by `BigInt` are not parametric—this is very much intentional, as -Swift generics cost us dearly at runtime in this use case. In every approach I tried, -making arbitrary-precision arithmetic operations work with a generic `Digit` type parameter -resulted in code that was literally *ten times slower*. If you can make the algorithms generic -without such a huge performance hit, [please enlighten me][twitter]! - -This is an area that I plan to investigate more, as it would be useful to have generic -implementations for arbitrary-width arithmetic operations. (Polynomial division and decimal bases -are two examples.) The library already implements double-digit multiplication and division as -extension methods on a protocol with an associated type requirement; this has not measurably affected -performance. Unfortunately, the same is not true for `BigUInt`'s methods. - -Of course, as a last resort, we could just duplicate the code to create a separate -generic variant that was slower but more flexible. - -[license]: https://github.com/attaswift/BigInt/blob/master/LICENSE.md -[twitter]: https://twitter.com/lorentey -[BigUInt]: http://attaswift.github.io/BigInt/Structs/BigUInt.html -[BigInt]: http://attaswift.github.io/BigInt/Structs/BigInt.html -[comparison]: http://attaswift.github.io/BigInt/Structs/BigUInt.html#/Comparison -[hashing]: http://attaswift.github.io/BigInt/Structs/BigUInt.html#/Hashing -[addition]: http://attaswift.github.io/BigInt/Structs/BigUInt.html#/Addition -[subtraction]: http://attaswift.github.io/BigInt/Structs/BigUInt.html#/Subtraction -[mul]: http://attaswift.github.io/BigInt/Structs/BigUInt.html#/s:ZFV6BigInt7BigUIntoi1mFTS0_S0__S0_ -[fused]: http://attaswift.github.io/BigInt/Structs/BigUInt.html#/s:FV6BigInt7BigUInt14multiplyAndAddFTS0_Vs6UInt6410atPositionSi_T_ -[multiplication]: http://attaswift.github.io/BigInt/Structs/BigUInt.html#/Multiplication -[division]: http://attaswift.github.io/BigInt/Structs/BigUInt.html#/Division -[divide]: http://attaswift.github.io/BigInt/Structs/BigUInt.html#/s:FV6BigInt7BigUInt7dividedFT2byS0__T8quotientS0_9remainderS0__ -[bitwise]: http://attaswift.github.io/BigInt/Structs/BigUInt.html#/Bitwise%20Operations -[width]: http://attaswift.github.io/BigInt/Structs/BigUInt.html#/s:vV6BigInt7BigUInt5widthSi -[leadingZeroBitCount]: http://attaswift.github.io/BigInt/Structs/BigUInt.html#/s:vV6BigInt7BigUInt13leadingZeroBitCountSi -[trailingZeroBitCount]: http://attaswift.github.io/BigInt/Structs/BigUInt.html#/s:vV6BigInt7BigUInt14trailingZeroBitCountSi -[shift]: http://attaswift.github.io/BigInt/Structs/BigUInt.html#/Shift%20Operators -[data]: http://attaswift.github.io/BigInt/Structs/BigUInt.html#/NSData%20Conversion -[random]: http://attaswift.github.io/BigInt/Structs/BigUInt.html#/Random%20Integers -[radix1]: http://attaswift.github.io/BigInt/Extensions/String.html#/s:FE6BigIntSScFTVS_7BigUInt5radixSi9uppercaseSb_SS -[radix2]: http://attaswift.github.io/BigInt/Structs/BigUInt.html#/s:FV6BigInt7BigUIntcFTSS5radixSi_GSqS0__ -[sqrt]: http://attaswift.github.io/BigInt/Functions.html#/s:F6BigInt4sqrtFVS_7BigUIntS0_ -[GCD]: http://attaswift.github.io/BigInt/Structs/BigUInt.html#/s:ZFV6BigInt7BigUInt3gcdFTS0_S0__S0_ -[powmod]: http://attaswift.github.io/BigInt/Structs/BigUInt.html#/s:FV6BigInt7BigUInt5powerFTS0_7modulusS0__S0_ -[power]: http://attaswift.github.io/BigInt/Structs/BigUInt.html#/s:FV6BigInt7BigUInt5powerFSiS0_ -[inverse]: http://attaswift.github.io/BigInt/Structs/BigUInt.html#/s:FV6BigInt7BigUInt7inverseFS0_GSqS0__ -[prime]: http://attaswift.github.io/BigInt/Structs/BigUInt.html#/Primality%20Testing -[abs]: http://attaswift.github.io/BigInt/Structs/BigInt.html#/s:vV6BigInt6BigInt3absVS_7BigUInt -[negative]: http://attaswift.github.io/BigInt/Structs/BigInt.html#/s:vV6BigInt6BigInt8negativeSb -[subscript]: https://github.com/attaswift/BigInt/blob/v2.0.0/Sources/BigUInt.swift#L216-L239 -[fullmuldiv]: https://github.com/attaswift/BigInt/blob/v2.0.0/Sources/BigDigit.swift#L96-L167 - - -## Calculation Samples - -### Obligatory Factorial Demo - -It is easy to use `BigInt` to calculate the factorial function for any integer: - -```Swift -import BigInt - -func factorial(_ n: Int) -> BigInt { - return (1 ... n).map { BigInt($0) }.reduce(BigInt(1), *) -} - -print(factorial(10)) -==> 362880 - -print(factorial(100)) -==> 93326215443944152681699238856266700490715968264381621468592963895217599993229915 - 6089414639761565182862536979208272237582511852109168640000000000000000000000 - -print(factorial(1000)) -==> 40238726007709377354370243392300398571937486421071463254379991042993851239862902 - 05920442084869694048004799886101971960586316668729948085589013238296699445909974 - 24504087073759918823627727188732519779505950995276120874975462497043601418278094 - 64649629105639388743788648733711918104582578364784997701247663288983595573543251 - 31853239584630755574091142624174743493475534286465766116677973966688202912073791 - 43853719588249808126867838374559731746136085379534524221586593201928090878297308 - 43139284440328123155861103697680135730421616874760967587134831202547858932076716 - 91324484262361314125087802080002616831510273418279777047846358681701643650241536 - 91398281264810213092761244896359928705114964975419909342221566832572080821333186 - 11681155361583654698404670897560290095053761647584772842188967964624494516076535 - 34081989013854424879849599533191017233555566021394503997362807501378376153071277 - 61926849034352625200015888535147331611702103968175921510907788019393178114194545 - 25722386554146106289218796022383897147608850627686296714667469756291123408243920 - 81601537808898939645182632436716167621791689097799119037540312746222899880051954 - 44414282012187361745992642956581746628302955570299024324153181617210465832036786 - 90611726015878352075151628422554026517048330422614397428693306169089796848259012 - 54583271682264580665267699586526822728070757813918581788896522081643483448259932 - 66043367660176999612831860788386150279465955131156552036093988180612138558600301 - 43569452722420634463179746059468257310379008402443243846565724501440282188525247 - 09351906209290231364932734975655139587205596542287497740114133469627154228458623 - 77387538230483865688976461927383814900140767310446640259899490222221765904339901 - 88601856652648506179970235619389701786004081188972991831102117122984590164192106 - 88843871218556461249607987229085192968193723886426148396573822911231250241866493 - 53143970137428531926649875337218940694281434118520158014123344828015051399694290 - 15348307764456909907315243327828826986460278986432113908350621709500259738986355 - 42771967428222487575867657523442202075736305694988250879689281627538488633969099 - 59826280956121450994871701244516461260379029309120889086942028510640182154399457 - 15680594187274899809425474217358240106367740459574178516082923013535808184009699 - 63725242305608559037006242712434169090041536901059339838357779394109700277534720 - 00000000000000000000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000000000000000000000000000000000000000 - 00000000000000000000000000000000000000000000000000000000000000000000000000000000 - 00000 -``` - -Well, I guess that's all right, but it's not very interesting. Let's try something more useful. - -### RSA Cryptography - -The `BigInt` module provides all necessary parts to implement an (overly) -simple [RSA cryptography system][RSA]. - -[RSA]: https://en.wikipedia.org/wiki/RSA_(cryptosystem) - -Let's start with a simple function that generates a random n-bit prime. The module -includes a function to generate random integers of a specific size, and also an -`isPrime` method that performs the Miller–Rabin primality test. These are all we need: - -```Swift -func generatePrime(_ width: Int) -> BigUInt { - while true { - var random = BigUInt.randomInteger(withExactWidth: width) - random |= BigUInt(1) - if random.isPrime() { - return random - } - } -} - -let p = generatePrime(1024) -==> 13308187650642192396256419911012544845370493728424936791561478318443071617242872 - 81980956747087187419914435169914161116601678883358611076800743580556055714173922 - 08406194264346635072293912609713085260354070700055888678514690878149253177960273 - 775659537560220378850112471985434373425534121373466492101182463962031 - -let q = generatePrime(1024) -==> 17072954422657145489547308812333368925007949054501204983863958355897172093173783 - 10108226596943999553784252564650624766276133157586733504784616138305701168410157 - 80784336308507083874651158029602582993233111593356512531869546706885170044355115 - 669728424124141763799008880327106952436883614887277350838425336156327 -``` - -Cool! Now that we have two large primes, we can produce an RSA public/private keypair -out of them. - -```Swift -typealias Key = (modulus: BigUInt, exponent: BigUInt) - -let n = p * q -==> 22721008120758282530010953362926306641542233757318103044313144976976529789946696 - 15454966720907712515917481418981591379647635391260569349099666410127279690367978 - 81184375533755888994370640857883754985364288413796100527262763202679037134021810 - 57933883525572232242690805678883227791774442041516929419640051653934584376704034 - 63953169772816907280591934423237977258358097846511079947337857778137177570668391 - 57455417707100275487770399281417352829897118140972240757708561027087217205975220 - 02207275447810167397968435583004676293892340103729490987263776871467057582629588 - 916498579594964478080508868267360515953225283461208420137 - -let e: BigUInt = 65537 -let phi = (p - 1) * (q - 1) -let d = e.inverse(phi)! // d * e % phi == 1 -==> 13964664343869014759736350480776837992604500903989703383202366291905558996277719 - 77822086142456362972689566985925179681282432115598451765899180050962461295573831 - 37069237934291884106584820998146965085531433195106686745474222222620986858696591 - 69836532468835154412554521152103642453158895363417640676611704542784576974374954 - 45789456921660619938185093118762690200980720312508614337759620606992462563490422 - 76669559556568917533268479190948959560397579572761529852891246283539604545691244 - 89999692877158676643042118662613875863504016129837099223040687512684532694527109 - 80742873307409704484365002175294665608486688146261327793 - -let publicKey: Key = (n, e) -let privateKey: Key = (n, d) -``` - -In RSA, modular exponentiation is used to encrypt (and decrypt) messages. - -```Swift -func encrypt(_ message: BigUInt, key: Key) -> BigUInt { - return message.power(key.exponent, modulus: key.modulus) -} -``` - -Let's try out our new keypair by converting a string into UTF-8, interpreting -the resulting binary representation as a big integer, and encrypting it with the -public key. `BigUInt` has an initializer that takes an `NSData`, so this is pretty -easy to do: - -```Swift -let secret: BigUInt = BigUInt("Arbitrary precision arithmetic is fun!".dataUsingEncoding(NSUTF8StringEncoding)!) -==> 83323446846105976078466731524728681905293067701804838925389198929123912971229457 - 68818568737 - -let cyphertext = encrypt(secret, key: publicKey) -==> 95186982543485985200666516508066093880038842892337880561554910904277290917831453 - 54854954722744805432145474047391353716305176389470779020645959135298322520888633 - 61674945129099575943384767330342554525120384485469428048962027149169876127890306 - 77028183904699491962050888974524603226290836984166164759586952419343589385279641 - 47999991283152843977988979846238236160274201261075188190509539751990119132013021 - 74866638595734222867005089157198503204192264814750832072844208520394603054901706 - 06024394731371973402595826456435944968439153664617188570808940022471990638468783 - 49208193955207336172861151720299024935127021719852700882 -``` - -Well, it looks encrypted all right, but can we get the original message back? -In theory, encrypting the cyphertext with the private key returns the original message. -Let's see: - -```Swift -let plaintext = encrypt(cyphertext, key: privateKey) -==> 83323446846105976078466731524728681905293067701804838925389198929123912971229457 - 68818568737 - -let received = String(data: plaintext.serialize(), encoding: NSUTF8StringEncoding) -==> "Arbitrary precision arithmetic is fun!" -``` - -Yay! This is truly terrific, but please don't use this example code in an actual -cryptography system. RSA has lots of subtle (and some not so subtle) complications -that we ignored to keep this example short. - -### Calculating the Digits of π - -Another fun activity to try with `BigInt`s is to generate the digits of π. -Let's try implementing [Jeremy Gibbon's spigot algorithm][spigot]. -This is a rather slow algorithm as π-generators go, but it makes up for it with its grooviness -factor: it's remarkably short, it only uses (big) integer arithmetic, and every iteration -produces a single new digit in the base-10 representation of π. This naturally leads to an -implementation as an infinite `GeneratorType`: - -[spigot]: http://www.cs.ox.ac.uk/jeremy.gibbons/publications/spigot.pdf - -```Swift -func digitsOfPi() -> AnyGenerator { - var q: BigUInt = 1 - var r: BigUInt = 180 - var t: BigUInt = 60 - var i: UInt64 = 2 // Does not overflow until digit #826_566_842 - return AnyIterator { - let u: UInt64 = 3 * (3 * i + 1) * (3 * i + 2) - let y = (q.multiplied(byDigit: 27 * i - 12) + 5 * r) / (5 * t) - (q, r, t) = ( - 10 * q.multiplied(byDigit: i * (2 * i - 1)), - 10 * (q.multiplied(byDigit: 5 * i - 2) + r - y * t).multiplied(byDigit: u), - t.multiplied(byDigit: u)) - i += 1 - return Int(y[0]) - } -} -``` - -Well, that was surprisingly easy. But does it work? Of course it does! - -```Swift -var digits = "π ≈ " -var count = 0 -for digit in digitsOfPi() { - assert(digit < 10) - digits += String(digit) - count += 1 - if count == 1 { digits += "." } - if count == 1000 { break } -} - -digits -==> π ≈ 3.14159265358979323846264338327950288419716939937510582097494459230781640628 - 62089986280348253421170679821480865132823066470938446095505822317253594081284811 - 17450284102701938521105559644622948954930381964428810975665933446128475648233786 - 78316527120190914564856692346034861045432664821339360726024914127372458700660631 - 55881748815209209628292540917153643678925903600113305305488204665213841469519415 - 11609433057270365759591953092186117381932611793105118548074462379962749567351885 - 75272489122793818301194912983367336244065664308602139494639522473719070217986094 - 37027705392171762931767523846748184676694051320005681271452635608277857713427577 - 89609173637178721468440901224953430146549585371050792279689258923542019956112129 - 02196086403441815981362977477130996051870721134999999837297804995105973173281609 - 63185950244594553469083026425223082533446850352619311881710100031378387528865875 - 33208381420617177669147303598253490428755468731159562863882353787593751957781857 - 780532171226806613001927876611195909216420198 -``` - -Now go and have some fun with big integers on your own! diff --git a/Carthage/Checkouts/BigInt/Sources/Addition.swift b/Carthage/Checkouts/BigInt/Sources/Addition.swift deleted file mode 100644 index 34f4d44e8..000000000 --- a/Carthage/Checkouts/BigInt/Sources/Addition.swift +++ /dev/null @@ -1,126 +0,0 @@ -// -// Addition.swift -// BigInt -// -// Created by Károly Lőrentey on 2016-01-03. -// Copyright © 2016-2017 Károly Lőrentey. -// - -extension BigUInt { - //MARK: Addition - - /// Add `word` to this integer in place. - /// `word` is shifted `shift` words to the left before being added. - /// - /// - Complexity: O(max(count, shift)) - internal mutating func addWord(_ word: Word, shiftedBy shift: Int = 0) { - precondition(shift >= 0) - var carry = word - var i = shift - while carry > 0 { - let (d, c) = self[i].addingReportingOverflow(carry) - self[i] = d - carry = (c ? 1 : 0) - i += 1 - } - } - - /// Add the digit `d` to this integer and return the result. - /// `d` is shifted `shift` words to the left before being added. - /// - /// - Complexity: O(max(count, shift)) - internal func addingWord(_ word: Word, shiftedBy shift: Int = 0) -> BigUInt { - var r = self - r.addWord(word, shiftedBy: shift) - return r - } - - /// Add `b` to this integer in place. - /// `b` is shifted `shift` words to the left before being added. - /// - /// - Complexity: O(max(count, b.count + shift)) - internal mutating func add(_ b: BigUInt, shiftedBy shift: Int = 0) { - precondition(shift >= 0) - var carry = false - var bi = 0 - let bc = b.count - while bi < bc || carry { - let ai = shift + bi - let (d, c) = self[ai].addingReportingOverflow(b[bi]) - if carry { - let (d2, c2) = d.addingReportingOverflow(1) - self[ai] = d2 - carry = c || c2 - } - else { - self[ai] = d - carry = c - } - bi += 1 - } - } - - /// Add `b` to this integer and return the result. - /// `b` is shifted `shift` words to the left before being added. - /// - /// - Complexity: O(max(count, b.count + shift)) - internal func adding(_ b: BigUInt, shiftedBy shift: Int = 0) -> BigUInt { - var r = self - r.add(b, shiftedBy: shift) - return r - } - - /// Increment this integer by one. If `shift` is non-zero, it selects - /// the word that is to be incremented. - /// - /// - Complexity: O(count + shift) - internal mutating func increment(shiftedBy shift: Int = 0) { - self.addWord(1, shiftedBy: shift) - } - - /// Add `a` and `b` together and return the result. - /// - /// - Complexity: O(max(a.count, b.count)) - public static func +(a: BigUInt, b: BigUInt) -> BigUInt { - return a.adding(b) - } - - /// Add `a` and `b` together, and store the sum in `a`. - /// - /// - Complexity: O(max(a.count, b.count)) - public static func +=(a: inout BigUInt, b: BigUInt) { - a.add(b, shiftedBy: 0) - } -} - -extension BigInt { - /// Add `a` to `b` and return the result. - public static func +(a: BigInt, b: BigInt) -> BigInt { - switch (a.sign, b.sign) { - case (.plus, .plus): - return BigInt(sign: .plus, magnitude: a.magnitude + b.magnitude) - case (.minus, .minus): - return BigInt(sign: .minus, magnitude: a.magnitude + b.magnitude) - case (.plus, .minus): - if a.magnitude >= b.magnitude { - return BigInt(sign: .plus, magnitude: a.magnitude - b.magnitude) - } - else { - return BigInt(sign: .minus, magnitude: b.magnitude - a.magnitude) - } - case (.minus, .plus): - if b.magnitude >= a.magnitude { - return BigInt(sign: .plus, magnitude: b.magnitude - a.magnitude) - } - else { - return BigInt(sign: .minus, magnitude: a.magnitude - b.magnitude) - } - } - } - - /// Add `b` to `a` in place. - public static func +=(a: inout BigInt, b: BigInt) { - a = a + b - } -} - diff --git a/Carthage/Checkouts/BigInt/Sources/BigInt.swift b/Carthage/Checkouts/BigInt/Sources/BigInt.swift deleted file mode 100644 index 11318ffcc..000000000 --- a/Carthage/Checkouts/BigInt/Sources/BigInt.swift +++ /dev/null @@ -1,74 +0,0 @@ -// -// BigInt.swift -// BigInt -// -// Created by Károly Lőrentey on 2015-12-27. -// Copyright © 2016-2017 Károly Lőrentey. -// - -//MARK: BigInt - -/// An arbitary precision signed integer type, also known as a "big integer". -/// -/// Operations on big integers never overflow, but they might take a long time to execute. -/// The amount of memory (and address space) available is the only constraint to the magnitude of these numbers. -/// -/// This particular big integer type uses base-2^64 digits to represent integers. -/// -/// `BigInt` is essentially a tiny wrapper that extends `BigUInt` with a sign bit and provides signed integer -/// operations. Both the underlying absolute value and the negative/positive flag are available as read-write -/// properties. -/// -/// Not all algorithms of `BigUInt` are available for `BigInt` values; for example, there is no square root or -/// primality test for signed integers. When you need to call one of these, just extract the absolute value: -/// -/// ```Swift -/// BigInt(255).abs.isPrime() // Returns false -/// ``` -/// -public struct BigInt: SignedInteger { - public enum Sign { - case plus - case minus - } - - public typealias Magnitude = BigUInt - - /// The type representing a digit in `BigInt`'s underlying number system. - public typealias Word = BigUInt.Word - - public static var isSigned: Bool { - return true - } - - /// The absolute value of this integer. - public var magnitude: BigUInt - - /// True iff the value of this integer is negative. - public var sign: Sign - - /// Initializes a new big integer with the provided absolute number and sign flag. - public init(sign: Sign, magnitude: BigUInt) { - self.sign = (magnitude.isZero ? .plus : sign) - self.magnitude = magnitude - } - - /// Return true iff this integer is zero. - /// - /// - Complexity: O(1) - public var isZero: Bool { - return magnitude.isZero - } - - /// Returns `-1` if this value is negative and `1` if it’s positive; otherwise, `0`. - /// - /// - Returns: The sign of this number, expressed as an integer of the same type. - public func signum() -> BigInt { - switch sign { - case .plus: - return isZero ? 0 : 1 - case .minus: - return -1 - } - } -} diff --git a/Carthage/Checkouts/BigInt/Sources/BigUInt.swift b/Carthage/Checkouts/BigInt/Sources/BigUInt.swift deleted file mode 100644 index 81aa9a837..000000000 --- a/Carthage/Checkouts/BigInt/Sources/BigUInt.swift +++ /dev/null @@ -1,386 +0,0 @@ -// -// BigUInt.swift -// BigInt -// -// Created by Károly Lőrentey on 2015-12-26. -// Copyright © 2016-2017 Károly Lőrentey. -// - -/// An arbitary precision unsigned integer type, also known as a "big integer". -/// -/// Operations on big integers never overflow, but they may take a long time to execute. -/// The amount of memory (and address space) available is the only constraint to the magnitude of these numbers. -/// -/// This particular big integer type uses base-2^64 digits to represent integers; you can think of it as a wrapper -/// around `Array`. (In fact, `BigUInt` only uses an array if there are more than two digits.) -public struct BigUInt: UnsignedInteger { - /// The type representing a digit in `BigUInt`'s underlying number system. - public typealias Word = UInt - - /// The storage variants of a `BigUInt`. - enum Kind { - /// Value consists of the two specified words (low and high). Either or both words may be zero. - case inline(Word, Word) - /// Words are stored in a slice of the storage array. - case slice(from: Int, to: Int) - /// Words are stored in the storage array. - case array - } - - internal fileprivate (set) var kind: Kind // Internal for testing only - internal fileprivate (set) var storage: [Word] // Internal for testing only; stored separately to prevent COW copies - - /// Initializes a new BigUInt with value 0. - public init() { - self.kind = .inline(0, 0) - self.storage = [] - } - - internal init(word: Word) { - self.kind = .inline(word, 0) - self.storage = [] - } - - internal init(low: Word, high: Word) { - self.kind = .inline(low, high) - self.storage = [] - } - - /// Initializes a new BigUInt with the specified digits. The digits are ordered from least to most significant. - public init(words: [Word]) { - self.kind = .array - self.storage = words - normalize() - } - - internal init(words: [Word], from startIndex: Int, to endIndex: Int) { - self.kind = .slice(from: startIndex, to: endIndex) - self.storage = words - normalize() - } -} - -extension BigUInt { - public static var isSigned: Bool { - return false - } - - /// Return true iff this integer is zero. - /// - /// - Complexity: O(1) - var isZero: Bool { - switch kind { - case .inline(0, 0): return true - case .array: return storage.isEmpty - default: - return false - } - } - - /// Returns `1` if this value is, positive; otherwise, `0`. - /// - /// - Returns: The sign of this number, expressed as an integer of the same type. - public func signum() -> BigUInt { - return isZero ? 0 : 1 - } -} - -extension BigUInt { - mutating func ensureArray() { - switch kind { - case let .inline(w0, w1): - kind = .array - storage = w1 != 0 ? [w0, w1] - : w0 != 0 ? [w0] - : [] - case let .slice(from: start, to: end): - kind = .array - storage = Array(storage[start ..< end]) - case .array: - break - } - } - - var capacity: Int { - guard case .array = kind else { return 0 } - return storage.capacity - } - - mutating func reserveCapacity(_ minimumCapacity: Int) { - switch kind { - case let .inline(w0, w1): - kind = .array - storage.reserveCapacity(minimumCapacity) - if w1 != 0 { - storage.append(w0) - storage.append(w1) - } - else if w0 != 0 { - storage.append(w0) - } - case let .slice(from: start, to: end): - kind = .array - var words: [Word] = [] - words.reserveCapacity(Swift.max(end - start, minimumCapacity)) - words.append(contentsOf: storage[start ..< end]) - storage = words - case .array: - storage.reserveCapacity(minimumCapacity) - } - } - - /// Gets rid of leading zero digits in the digit array and converts slices into inline digits when possible. - internal mutating func normalize() { - switch kind { - case .slice(from: let start, to: var end): - assert(start >= 0 && end <= storage.count && start <= end) - while start < end, storage[end - 1] == 0 { - end -= 1 - } - switch end - start { - case 0: - kind = .inline(0, 0) - storage = [] - case 1: - kind = .inline(storage[start], 0) - storage = [] - case 2: - kind = .inline(storage[start], storage[start + 1]) - storage = [] - case storage.count: - assert(start == 0) - kind = .array - default: - kind = .slice(from: start, to: end) - } - case .array where storage.last == 0: - while storage.last == 0 { - storage.removeLast() - } - default: - break - } - } - - /// Set this integer to 0 without releasing allocated storage capacity (if any). - mutating func clear() { - self.load(0) - } - - /// Set this integer to `value` by copying its digits without releasing allocated storage capacity (if any). - mutating func load(_ value: BigUInt) { - switch kind { - case .inline, .slice: - self = value - case .array: - self.storage.removeAll(keepingCapacity: true) - self.storage.append(contentsOf: value.words) - } - } -} - -extension BigUInt { - //MARK: Collection-like members - - /// The number of digits in this integer, excluding leading zero digits. - var count: Int { - switch kind { - case let .inline(w0, w1): - return w1 != 0 ? 2 - : w0 != 0 ? 1 - : 0 - case let .slice(from: start, to: end): - return end - start - case .array: - return storage.count - } - } - - /// Get or set a digit at a given index. - /// - /// - Note: Unlike a normal collection, it is OK for the index to be greater than or equal to `endIndex`. - /// The subscripting getter returns zero for indexes beyond the most significant digit. - /// Setting these extended digits automatically appends new elements to the underlying digit array. - /// - Requires: index >= 0 - /// - Complexity: The getter is O(1). The setter is O(1) if the conditions below are true; otherwise it's O(count). - /// - The integer's storage is not shared with another integer - /// - The integer wasn't created as a slice of another integer - /// - `index < count` - subscript(_ index: Int) -> Word { - get { - precondition(index >= 0) - switch (kind, index) { - case (.inline(let w0, _), 0): return w0 - case (.inline(_, let w1), 1): return w1 - case (.slice(from: let start, to: let end), _) where index < end - start: - return storage[start + index] - case (.array, _) where index < storage.count: - return storage[index] - default: - return 0 - } - } - set(word) { - precondition(index >= 0) - switch (kind, index) { - case let (.inline(_, w1), 0): - kind = .inline(word, w1) - case let (.inline(w0, _), 1): - kind = .inline(w0, word) - case let (.slice(from: start, to: end), _) where index < end - start: - replace(at: index, with: word) - case (.array, _) where index < storage.count: - replace(at: index, with: word) - default: - extend(at: index, with: word) - } - } - } - - private mutating func replace(at index: Int, with word: Word) { - ensureArray() - precondition(index < storage.count) - storage[index] = word - if word == 0, index == storage.count - 1 { - normalize() - } - } - - private mutating func extend(at index: Int, with word: Word) { - guard word != 0 else { return } - reserveCapacity(index + 1) - precondition(index >= storage.count) - storage.append(contentsOf: repeatElement(0, count: index - storage.count)) - storage.append(word) - } - - /// Returns an integer built from the digits of this integer in the given range. - internal func extract(_ bounds: Range) -> BigUInt { - switch kind { - case let .inline(w0, w1): - let bounds = bounds.clamped(to: 0 ..< 2) - if bounds == 0 ..< 2 { - return BigUInt(low: w0, high: w1) - } - else if bounds == 0 ..< 1 { - return BigUInt(word: w0) - } - else if bounds == 1 ..< 2 { - return BigUInt(word: w1) - } - else { - return BigUInt() - } - case let .slice(from: start, to: end): - let s = Swift.min(end, start + Swift.max(bounds.lowerBound, 0)) - let e = Swift.max(s, (bounds.upperBound > end - start ? end : start + bounds.upperBound)) - return BigUInt(words: storage, from: s, to: e) - case .array: - let b = bounds.clamped(to: storage.startIndex ..< storage.endIndex) - return BigUInt(words: storage, from: b.lowerBound, to: b.upperBound) - } - } - - internal func extract(_ bounds: Bounds) -> BigUInt where Bounds.Bound == Int { - return self.extract(bounds.relative(to: 0 ..< Int.max)) - } -} - -extension BigUInt { - internal mutating func shiftRight(byWords amount: Int) { - assert(amount >= 0) - guard amount > 0 else { return } - switch kind { - case let .inline(_, w1) where amount == 1: - kind = .inline(w1, 0) - case .inline(_, _): - kind = .inline(0, 0) - case let .slice(from: start, to: end): - let s = start + amount - if s >= end { - kind = .inline(0, 0) - } - else { - kind = .slice(from: s, to: end) - normalize() - } - case .array: - if amount >= storage.count { - storage.removeAll(keepingCapacity: true) - } - else { - storage.removeFirst(amount) - } - } - } - - internal mutating func shiftLeft(byWords amount: Int) { - assert(amount >= 0) - guard amount > 0 else { return } - guard !isZero else { return } - switch kind { - case let .inline(w0, 0) where amount == 1: - kind = .inline(0, w0) - case let .inline(w0, w1): - let c = (w1 == 0 ? 1 : 2) - storage.reserveCapacity(amount + c) - storage.append(contentsOf: repeatElement(0, count: amount)) - storage.append(w0) - if w1 != 0 { - storage.append(w1) - } - kind = .array - case let .slice(from: start, to: end): - var words: [Word] = [] - words.reserveCapacity(amount + count) - words.append(contentsOf: repeatElement(0, count: amount)) - words.append(contentsOf: storage[start ..< end]) - storage = words - kind = .array - case .array: - storage.insert(contentsOf: repeatElement(0, count: amount), at: 0) - } - } -} - -extension BigUInt { - //MARK: Low and High - - /// Split this integer into a high-order and a low-order part. - /// - /// - Requires: count > 1 - /// - Returns: `(low, high)` such that - /// - `self == low.add(high, shiftedBy: middleIndex)` - /// - `high.width <= floor(width / 2)` - /// - `low.width <= ceil(width / 2)` - /// - Complexity: Typically O(1), but O(count) in the worst case, because high-order zero digits need to be removed after the split. - internal var split: (high: BigUInt, low: BigUInt) { - precondition(count > 1) - let mid = middleIndex - return (self.extract(mid...), self.extract(.. 1 - internal var low: BigUInt { - return self.extract(0 ..< middleIndex) - } - - /// The high-order half of this BigUInt. - /// - /// - Returns: `self[middleIndex ..< count]` - /// - Requires: count > 1 - internal var high: BigUInt { - return self.extract(middleIndex ..< count) - } -} - diff --git a/Carthage/Checkouts/BigInt/Sources/Bitwise Ops.swift b/Carthage/Checkouts/BigInt/Sources/Bitwise Ops.swift deleted file mode 100644 index 0d00148bd..000000000 --- a/Carthage/Checkouts/BigInt/Sources/Bitwise Ops.swift +++ /dev/null @@ -1,121 +0,0 @@ -// -// Bitwise Ops.swift -// BigInt -// -// Created by Károly Lőrentey on 2016-01-03. -// Copyright © 2016-2017 Károly Lőrentey. -// - -//MARK: Bitwise Operations - -extension BigUInt { - /// Return the ones' complement of `a`. - /// - /// - Complexity: O(a.count) - public static prefix func ~(a: BigUInt) -> BigUInt { - return BigUInt(words: a.words.map { ~$0 }) - } - - /// Calculate the bitwise OR of `a` and `b`, and store the result in `a`. - /// - /// - Complexity: O(max(a.count, b.count)) - public static func |= (a: inout BigUInt, b: BigUInt) { - a.reserveCapacity(b.count) - for i in 0 ..< b.count { - a[i] |= b[i] - } - } - - /// Calculate the bitwise AND of `a` and `b` and return the result. - /// - /// - Complexity: O(max(a.count, b.count)) - public static func &= (a: inout BigUInt, b: BigUInt) { - for i in 0 ..< Swift.max(a.count, b.count) { - a[i] &= b[i] - } - } - - /// Calculate the bitwise XOR of `a` and `b` and return the result. - /// - /// - Complexity: O(max(a.count, b.count)) - public static func ^= (a: inout BigUInt, b: BigUInt) { - a.reserveCapacity(b.count) - for i in 0 ..< b.count { - a[i] ^= b[i] - } - } -} - -extension BigInt { - public static prefix func ~(x: BigInt) -> BigInt { - switch x.sign { - case .plus: - return BigInt(sign: .minus, magnitude: x.magnitude + 1) - case .minus: - return BigInt(sign: .plus, magnitude: x.magnitude - 1) - } - } - - public static func &(lhs: inout BigInt, rhs: BigInt) -> BigInt { - let left = lhs.words - let right = rhs.words - // Note we aren't using left.count/right.count here; we account for the sign bit separately later. - let count = Swift.max(lhs.magnitude.count, rhs.magnitude.count) - var words: [UInt] = [] - words.reserveCapacity(count) - for i in 0 ..< count { - words.append(left[i] & right[i]) - } - if lhs.sign == .minus && rhs.sign == .minus { - words.twosComplement() - return BigInt(sign: .minus, magnitude: BigUInt(words: words)) - } - return BigInt(sign: .plus, magnitude: BigUInt(words: words)) - } - - public static func |(lhs: inout BigInt, rhs: BigInt) -> BigInt { - let left = lhs.words - let right = rhs.words - // Note we aren't using left.count/right.count here; we account for the sign bit separately later. - let count = Swift.max(lhs.magnitude.count, rhs.magnitude.count) - var words: [UInt] = [] - words.reserveCapacity(count) - for i in 0 ..< count { - words.append(left[i] | right[i]) - } - if lhs.sign == .minus || rhs.sign == .minus { - words.twosComplement() - return BigInt(sign: .minus, magnitude: BigUInt(words: words)) - } - return BigInt(sign: .plus, magnitude: BigUInt(words: words)) - } - - public static func ^(lhs: inout BigInt, rhs: BigInt) -> BigInt { - let left = lhs.words - let right = rhs.words - // Note we aren't using left.count/right.count here; we account for the sign bit separately later. - let count = Swift.max(lhs.magnitude.count, rhs.magnitude.count) - var words: [UInt] = [] - words.reserveCapacity(count) - for i in 0 ..< count { - words.append(left[i] ^ right[i]) - } - if (lhs.sign == .minus) != (rhs.sign == .minus) { - words.twosComplement() - return BigInt(sign: .minus, magnitude: BigUInt(words: words)) - } - return BigInt(sign: .plus, magnitude: BigUInt(words: words)) - } - - public static func &=(lhs: inout BigInt, rhs: BigInt) { - lhs = lhs & rhs - } - - public static func |=(lhs: inout BigInt, rhs: BigInt) { - lhs = lhs | rhs - } - - public static func ^=(lhs: inout BigInt, rhs: BigInt) { - lhs = lhs ^ rhs - } -} diff --git a/Carthage/Checkouts/BigInt/Sources/Codable.swift b/Carthage/Checkouts/BigInt/Sources/Codable.swift deleted file mode 100644 index b53b30be5..000000000 --- a/Carthage/Checkouts/BigInt/Sources/Codable.swift +++ /dev/null @@ -1,155 +0,0 @@ -// -// Codable.swift -// BigInt -// -// Created by Károly Lőrentey on 2017-8-11. -// Copyright © 2016-2017 Károly Lőrentey. -// - - -// Little-endian to big-endian -struct Units: RandomAccessCollection -where Words.Element: FixedWidthInteger, Words.Index == Int { - typealias Word = Words.Element - let words: Words - init(of type: Unit.Type, _ words: Words) { - precondition(Word.bitWidth % Unit.bitWidth == 0 || Unit.bitWidth % Word.bitWidth == 0) - self.words = words - } - var count: Int { return (words.count * Word.bitWidth + Unit.bitWidth - 1) / Unit.bitWidth } - var startIndex: Int { return 0 } - var endIndex: Int { return count } - subscript(_ index: Int) -> Unit { - let index = count - 1 - index - if Unit.bitWidth == Word.bitWidth { - return Unit(words[index]) - } - else if Unit.bitWidth > Word.bitWidth { - let c = Unit.bitWidth / Word.bitWidth - var unit: Unit = 0 - var j = 0 - for i in (c * index) ..< Swift.min(c * (index + 1), words.endIndex) { - unit |= Unit(words[i]) << j - j += Word.bitWidth - } - return unit - } - // Unit.bitWidth < Word.bitWidth - let c = Word.bitWidth / Unit.bitWidth - let i = index / c - let j = index % c - return Unit(truncatingIfNeeded: words[i] >> (j * Unit.bitWidth)) - } -} - -extension Array where Element: FixedWidthInteger { - // Big-endian to little-endian - init(count: Int?, generator: () throws -> Unit?) rethrows { - typealias Word = Element - precondition(Word.bitWidth % Unit.bitWidth == 0 || Unit.bitWidth % Word.bitWidth == 0) - self = [] - if Unit.bitWidth == Word.bitWidth { - if let count = count { - self.reserveCapacity(count) - } - while let unit = try generator() { - self.append(Word(unit)) - } - } - else if Unit.bitWidth > Word.bitWidth { - let wordsPerUnit = Unit.bitWidth / Word.bitWidth - if let count = count { - self.reserveCapacity(count * wordsPerUnit) - } - while let unit = try generator() { - var shift = Unit.bitWidth - Word.bitWidth - while shift >= 0 { - self.append(Word(truncatingIfNeeded: unit >> shift)) - shift -= Word.bitWidth - } - } - } - else { - let unitsPerWord = Word.bitWidth / Unit.bitWidth - if let count = count { - self.reserveCapacity((count + unitsPerWord - 1) / unitsPerWord) - } - var word: Word = 0 - var c = 0 - while let unit = try generator() { - word <<= Unit.bitWidth - word |= Word(unit) - c += Unit.bitWidth - if c == Word.bitWidth { - self.append(word) - word = 0 - c = 0 - } - } - if c > 0 { - self.append(word << c) - var shifted: Word = 0 - for i in self.indices { - let word = self[i] - self[i] = shifted | (word >> c) - shifted = word << (Word.bitWidth - c) - } - } - } - self.reverse() - } -} - -extension BigInt: Codable { - public init(from decoder: Decoder) throws { - var container = try decoder.unkeyedContainer() - - // Decode sign - let sign: BigInt.Sign - switch try container.decode(String.self) { - case "+": - sign = .plus - case "-": - sign = .minus - default: - throw DecodingError.dataCorrupted(.init(codingPath: container.codingPath, - debugDescription: "Invalid big integer sign")) - } - - // Decode magnitude - let words = try [UInt](count: container.count?.advanced(by: -1)) { () -> UInt64? in - guard !container.isAtEnd else { return nil } - return try container.decode(UInt64.self) - } - let magnitude = BigUInt(words: words) - - self.init(sign: sign, magnitude: magnitude) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.unkeyedContainer() - try container.encode(sign == .plus ? "+" : "-") - let units = Units(of: UInt64.self, self.magnitude.words) - if units.isEmpty { - try container.encode(0 as UInt64) - } - else { - try container.encode(contentsOf: units) - } - } -} - -extension BigUInt: Codable { - public init(from decoder: Decoder) throws { - let value = try BigInt(from: decoder) - guard value.sign == .plus else { - throw DecodingError.dataCorrupted(.init(codingPath: decoder.codingPath, - debugDescription: "BigUInt cannot hold a negative value")) - } - self = value.magnitude - } - - public func encode(to encoder: Encoder) throws { - try BigInt(sign: .plus, magnitude: self).encode(to: encoder) - } -} diff --git a/Carthage/Checkouts/BigInt/Sources/Comparable.swift b/Carthage/Checkouts/BigInt/Sources/Comparable.swift deleted file mode 100644 index d9ab87e7e..000000000 --- a/Carthage/Checkouts/BigInt/Sources/Comparable.swift +++ /dev/null @@ -1,63 +0,0 @@ -// -// Comparable.swift -// BigInt -// -// Created by Károly Lőrentey on 2016-01-03. -// Copyright © 2016-2017 Károly Lőrentey. -// - -import Foundation - -extension BigUInt: Comparable { - //MARK: Comparison - - /// Compare `a` to `b` and return an `NSComparisonResult` indicating their order. - /// - /// - Complexity: O(count) - public static func compare(_ a: BigUInt, _ b: BigUInt) -> ComparisonResult { - if a.count != b.count { return a.count > b.count ? .orderedDescending : .orderedAscending } - for i in (0 ..< a.count).reversed() { - let ad = a[i] - let bd = b[i] - if ad != bd { return ad > bd ? .orderedDescending : .orderedAscending } - } - return .orderedSame - } - - /// Return true iff `a` is equal to `b`. - /// - /// - Complexity: O(count) - public static func ==(a: BigUInt, b: BigUInt) -> Bool { - return BigUInt.compare(a, b) == .orderedSame - } - - /// Return true iff `a` is less than `b`. - /// - /// - Complexity: O(count) - public static func <(a: BigUInt, b: BigUInt) -> Bool { - return BigUInt.compare(a, b) == .orderedAscending - } -} - -extension BigInt { - /// Return true iff `a` is equal to `b`. - public static func ==(a: BigInt, b: BigInt) -> Bool { - return a.sign == b.sign && a.magnitude == b.magnitude - } - - /// Return true iff `a` is less than `b`. - public static func <(a: BigInt, b: BigInt) -> Bool { - switch (a.sign, b.sign) { - case (.plus, .plus): - return a.magnitude < b.magnitude - case (.plus, .minus): - return false - case (.minus, .plus): - return true - case (.minus, .minus): - return a.magnitude > b.magnitude - } - } -} - - diff --git a/Carthage/Checkouts/BigInt/Sources/Data Conversion.swift b/Carthage/Checkouts/BigInt/Sources/Data Conversion.swift deleted file mode 100644 index 25c65521d..000000000 --- a/Carthage/Checkouts/BigInt/Sources/Data Conversion.swift +++ /dev/null @@ -1,179 +0,0 @@ -// -// Data Conversion.swift -// BigInt -// -// Created by Károly Lőrentey on 2016-01-04. -// Copyright © 2016-2017 Károly Lőrentey. -// - -import Foundation - -extension BigUInt { - //MARK: NSData Conversion - - /// Initialize a BigInt from bytes accessed from an UnsafeRawBufferPointer - public init(_ buffer: UnsafeRawBufferPointer) { - // This assumes Word is binary. - precondition(Word.bitWidth % 8 == 0) - - self.init() - - let length = buffer.count - guard length > 0 else { return } - let bytesPerDigit = Word.bitWidth / 8 - var index = length / bytesPerDigit - var c = bytesPerDigit - length % bytesPerDigit - if c == bytesPerDigit { - c = 0 - index -= 1 - } - - var word: Word = 0 - for byte in buffer { - word <<= 8 - word += Word(byte) - c += 1 - if c == bytesPerDigit { - self[index] = word - index -= 1 - c = 0 - word = 0 - } - } - assert(c == 0 && word == 0 && index == -1) - } - - - /// Initializes an integer from the bits stored inside a piece of `Data`. - /// The data is assumed to be in network (big-endian) byte order. - public init(_ data: Data) { - // This assumes Word is binary. - precondition(Word.bitWidth % 8 == 0) - - self.init() - - let length = data.count - guard length > 0 else { return } - let bytesPerDigit = Word.bitWidth / 8 - var index = length / bytesPerDigit - var c = bytesPerDigit - length % bytesPerDigit - if c == bytesPerDigit { - c = 0 - index -= 1 - } - let word: Word = data.withUnsafeBytes { buffPtr in - var word: Word = 0 - let p = buffPtr.bindMemory(to: UInt8.self) - for byte in p { - word <<= 8 - word += Word(byte) - c += 1 - if c == bytesPerDigit { - self[index] = word - index -= 1 - c = 0 - word = 0 - } - } - return word - } - assert(c == 0 && word == 0 && index == -1) - } - - /// Return a `Data` value that contains the base-256 representation of this integer, in network (big-endian) byte order. - public func serialize() -> Data { - // This assumes Digit is binary. - precondition(Word.bitWidth % 8 == 0) - - let byteCount = (self.bitWidth + 7) / 8 - - guard byteCount > 0 else { return Data() } - - var data = Data(count: byteCount) - data.withUnsafeMutableBytes { buffPtr in - let p = buffPtr.bindMemory(to: UInt8.self) - var i = byteCount - 1 - for var word in self.words { - for _ in 0 ..< Word.bitWidth / 8 { - p[i] = UInt8(word & 0xFF) - word >>= 8 - if i == 0 { - assert(word == 0) - break - } - i -= 1 - } - } - } - return data - } -} - -extension BigInt { - - /// Initialize a BigInt from bytes accessed from an UnsafeRawBufferPointer, - /// where the first byte indicates sign (0 for positive, 1 for negative) - public init(_ buffer: UnsafeRawBufferPointer) { - // This assumes Word is binary. - precondition(Word.bitWidth % 8 == 0) - - self.init() - - let length = buffer.count - - // Serialized data for a BigInt should contain at least 2 bytes: one representing - // the sign, and another for the non-zero magnitude. Zero is represented by an - // empty Data struct, and negative zero is not supported. - guard length > 1, let firstByte = buffer.first else { return } - - // The first byte gives the sign - // This byte is compared to a bitmask to allow additional functionality to be added - // to this byte in the future. - self.sign = firstByte & 0b1 == 0 ? .plus : .minus - - self.magnitude = BigUInt(UnsafeRawBufferPointer(rebasing: buffer.dropFirst(1))) - } - - /// Initializes an integer from the bits stored inside a piece of `Data`. - /// The data is assumed to be in network (big-endian) byte order with a first - /// byte to represent the sign (0 for positive, 1 for negative) - public init(_ data: Data) { - // This assumes Word is binary. - // This is the same assumption made when initializing BigUInt from Data - precondition(Word.bitWidth % 8 == 0) - - self.init() - - // Serialized data for a BigInt should contain at least 2 bytes: one representing - // the sign, and another for the non-zero magnitude. Zero is represented by an - // empty Data struct, and negative zero is not supported. - guard data.count > 1, let firstByte = data.first else { return } - - // The first byte gives the sign - // This byte is compared to a bitmask to allow additional functionality to be added - // to this byte in the future. - self.sign = firstByte & 0b1 == 0 ? .plus : .minus - - // The remaining bytes are read and stored as the magnitude - self.magnitude = BigUInt(data.dropFirst(1)) - } - - /// Return a `Data` value that contains the base-256 representation of this integer, in network (big-endian) byte order and a prepended byte to indicate the sign (0 for positive, 1 for negative) - public func serialize() -> Data { - // Create a data object for the magnitude portion of the BigInt - let magnitudeData = self.magnitude.serialize() - - // Similar to BigUInt, a value of 0 should return an initialized, empty Data struct - guard magnitudeData.count > 0 else { return magnitudeData } - - // Create a new Data struct for the signed BigInt value - var data = Data(capacity: magnitudeData.count + 1) - - // The first byte should be 0 for a positive value, or 1 for a negative value - // i.e., the sign bit is the LSB - data.append(self.sign == .plus ? 0 : 1) - - data.append(magnitudeData) - return data - } -} diff --git a/Carthage/Checkouts/BigInt/Sources/Division.swift b/Carthage/Checkouts/BigInt/Sources/Division.swift deleted file mode 100644 index 4393f52e9..000000000 --- a/Carthage/Checkouts/BigInt/Sources/Division.swift +++ /dev/null @@ -1,374 +0,0 @@ -// -// Division.swift -// BigInt -// -// Created by Károly Lőrentey on 2016-01-03. -// Copyright © 2016-2017 Károly Lőrentey. -// - -//MARK: Full-width multiplication and division - -extension FixedWidthInteger where Magnitude == Self { - private var halfShift: Self { - return Self(Self.bitWidth / 2) - - } - private var high: Self { - return self &>> halfShift - } - - private var low: Self { - let mask: Self = 1 &<< halfShift - 1 - return self & mask - } - - private var upshifted: Self { - return self &<< halfShift - } - - private var split: (high: Self, low: Self) { - return (self.high, self.low) - } - - private init(_ value: (high: Self, low: Self)) { - self = value.high.upshifted + value.low - } - - /// Divide the double-width integer `dividend` by `self` and return the quotient and remainder. - /// - /// - Requires: `dividend.high < self`, so that the result will fit in a single digit. - /// - Complexity: O(1) with 2 divisions, 6 multiplications and ~12 or so additions/subtractions. - internal func fastDividingFullWidth(_ dividend: (high: Self, low: Self.Magnitude)) -> (quotient: Self, remainder: Self) { - // Division is complicated; doing it with single-digit operations is maddeningly complicated. - // This is a Swift adaptation for "divlu2" in Hacker's Delight, - // which is in turn a C adaptation of Knuth's Algorithm D (TAOCP vol 2, 4.3.1). - precondition(dividend.high < self) - - // This replaces the implementation in stdlib, which is much slower. - // FIXME: Speed up stdlib. It should use full-width idiv on Intel processors, and - // fall back to a reasonably fast algorithm elsewhere. - - // The trick here is that we're actually implementing a 4/2 long division using half-words, - // with the long division loop unrolled into two 3/2 half-word divisions. - // Luckily, 3/2 half-word division can be approximated by a single full-word division operation - // that, when the divisor is normalized, differs from the correct result by at most 2. - - /// Find the half-word quotient in `u / vn`, which must be normalized. - /// `u` contains three half-words in the two halves of `u.high` and the lower half of - /// `u.low`. (The weird distribution makes for a slightly better fit with the input.) - /// `vn` contains the normalized divisor, consisting of two half-words. - /// - /// - Requires: u.high < vn && u.low.high == 0 && vn.leadingZeroBitCount == 0 - func quotient(dividing u: (high: Self, low: Self), by vn: Self) -> Self { - let (vn1, vn0) = vn.split - // Get approximate quotient. - let (q, r) = u.high.quotientAndRemainder(dividingBy: vn1) - let p = q * vn0 - // q is often already correct, but sometimes the approximation overshoots by at most 2. - // The code that follows checks for this while being careful to only perform single-digit operations. - if q.high == 0 && p <= r.upshifted + u.low { return q } - let r2 = r + vn1 - if r2.high != 0 { return q - 1 } - if (q - 1).high == 0 && p - vn0 <= r2.upshifted + u.low { return q - 1 } - //assert((r + 2 * vn1).high != 0 || p - 2 * vn0 <= (r + 2 * vn1).upshifted + u.low) - return q - 2 - } - /// Divide 3 half-digits by 2 half-digits to get a half-digit quotient and a full-digit remainder. - /// - /// - Requires: u.high < v && u.low.high == 0 && vn.width = width(Digit) - func quotientAndRemainder(dividing u: (high: Self, low: Self), by v: Self) -> (quotient: Self, remainder: Self) { - let q = quotient(dividing: u, by: v) - // Note that `uh.low` masks off a couple of bits, and `q * v` and the - // subtraction are likely to overflow. Despite this, the end result (remainder) will - // still be correct and it will fit inside a single (full) Digit. - let r = Self(u) &- q &* v - assert(r < v) - return (q, r) - } - - // Normalize the dividend and the divisor (self) such that the divisor has no leading zeroes. - let z = Self(self.leadingZeroBitCount) - let w = Self(Self.bitWidth) - z - let vn = self << z - - let un32 = (z == 0 ? dividend.high : (dividend.high &<< z) | (dividend.low &>> w)) // No bits are lost - let un10 = dividend.low &<< z - let (un1, un0) = un10.split - - // Divide `(un32,un10)` by `vn`, splitting the full 4/2 division into two 3/2 ones. - let (q1, un21) = quotientAndRemainder(dividing: (un32, un1), by: vn) - let (q0, rn) = quotientAndRemainder(dividing: (un21, un0), by: vn) - - // Undo normalization of the remainder and combine the two halves of the quotient. - let mod = rn >> z - let div = Self((q1, q0)) - return (div, mod) - } - - /// Return the quotient of the 3/2-word division `x/y` as a single word. - /// - /// - Requires: (x.0, x.1) <= y && y.0.high != 0 - /// - Returns: The exact value when it fits in a single word, otherwise `Self`. - static func approximateQuotient(dividing x: (Self, Self, Self), by y: (Self, Self)) -> Self { - // Start with q = (x.0, x.1) / y.0, (or Word.max on overflow) - var q: Self - var r: Self - if x.0 == y.0 { - q = Self.max - let (s, o) = x.0.addingReportingOverflow(x.1) - if o { return q } - r = s - } - else { - (q, r) = y.0.fastDividingFullWidth((x.0, x.1)) - } - // Now refine q by considering x.2 and y.1. - // Note that since y is normalized, q * y - x is between 0 and 2. - let (ph, pl) = q.multipliedFullWidth(by: y.1) - if ph < r || (ph == r && pl <= x.2) { return q } - - let (r1, ro) = r.addingReportingOverflow(y.0) - if ro { return q - 1 } - - let (pl1, so) = pl.subtractingReportingOverflow(y.1) - let ph1 = (so ? ph - 1 : ph) - - if ph1 < r1 || (ph1 == r1 && pl1 <= x.2) { return q - 1 } - return q - 2 - } -} - -extension BigUInt { - //MARK: Division - - /// Divide this integer by the word `y`, leaving the quotient in its place and returning the remainder. - /// - /// - Requires: y > 0 - /// - Complexity: O(count) - internal mutating func divide(byWord y: Word) -> Word { - precondition(y > 0) - if y == 1 { return 0 } - - var remainder: Word = 0 - for i in (0 ..< count).reversed() { - let u = self[i] - (self[i], remainder) = y.fastDividingFullWidth((remainder, u)) - } - return remainder - } - - /// Divide this integer by the word `y` and return the resulting quotient and remainder. - /// - /// - Requires: y > 0 - /// - Returns: (quotient, remainder) where quotient = floor(x/y), remainder = x - quotient * y - /// - Complexity: O(x.count) - internal func quotientAndRemainder(dividingByWord y: Word) -> (quotient: BigUInt, remainder: Word) { - var div = self - let mod = div.divide(byWord: y) - return (div, mod) - } - - /// Divide `x` by `y`, putting the quotient in `x` and the remainder in `y`. - /// Reusing integers like this reduces the number of allocations during the calculation. - static func divide(_ x: inout BigUInt, by y: inout BigUInt) { - // This is a Swift adaptation of "divmnu" from Hacker's Delight, which is in - // turn a C adaptation of Knuth's Algorithm D (TAOCP vol 2, 4.3.1). - - precondition(!y.isZero) - - // First, let's take care of the easy cases. - if x < y { - (x, y) = (0, x) - return - } - if y.count == 1 { - // The single-word case reduces to a simpler loop. - y = BigUInt(x.divide(byWord: y[0])) - return - } - - // In the hard cases, we will perform the long division algorithm we learned in school. - // It works by successively calculating the single-word quotient of the top y.count + 1 - // words of x divided by y, replacing the top of x with the remainder, and repeating - // the process one word lower. - // - // The tricky part is that the algorithm needs to be able to do n+1/n word divisions, - // but we only have a primitive for dividing two words by a single - // word. (Remember that this step is also tricky when we do it on paper!) - // - // The solution is that the long division can be approximated by a single full division - // using just the most significant words. We can then use multiplications and - // subtractions to refine the approximation until we get the correct quotient word. - // - // We could do this by doing a simple 2/1 full division, but Knuth goes one step further, - // and implements a 3/2 division. This results in an exact approximation in the - // vast majority of cases, eliminating an extra subtraction over big integers. - // - // The function `approximateQuotient` above implements Knuth's 3/2 division algorithm. - // It requires that the divisor's most significant word is larger than - // Word.max / 2. This ensures that the approximation has tiny error bounds, - // which is what makes this entire approach viable. - // To satisfy this requirement, we will normalize the division by multiplying - // both the divisor and the dividend by the same (small) factor. - let z = y.leadingZeroBitCount - y <<= z - x <<= z // We'll calculate the remainder in the normalized dividend. - var quotient = BigUInt() - assert(y.leadingZeroBitCount == 0) - - // We're ready to start the long division! - let dc = y.count - let d1 = y[dc - 1] - let d0 = y[dc - 2] - var product: BigUInt = 0 - for j in (dc ... x.count).reversed() { - // Approximate dividing the top dc+1 words of `remainder` using the topmost 3/2 words. - let r2 = x[j] - let r1 = x[j - 1] - let r0 = x[j - 2] - let q = Word.approximateQuotient(dividing: (r2, r1, r0), by: (d1, d0)) - - // Multiply the entire divisor with `q` and subtract the result from remainder. - // Normalization ensures the 3/2 quotient will either be exact for the full division, or - // it may overshoot by at most 1, in which case the product will be greater - // than the remainder. - product.load(y) - product.multiply(byWord: q) - if product <= x.extract(j - dc ..< j + 1) { - x.subtract(product, shiftedBy: j - dc) - quotient[j - dc] = q - } - else { - // This case is extremely rare -- it has a probability of 1/2^(Word.bitWidth - 1). - x.add(y, shiftedBy: j - dc) - x.subtract(product, shiftedBy: j - dc) - quotient[j - dc] = q - 1 - } - } - // The remainder's normalization needs to be undone, but otherwise we're done. - x >>= z - y = x - x = quotient - } - - /// Divide `x` by `y`, putting the remainder in `x`. - mutating func formRemainder(dividingBy y: BigUInt, normalizedBy shift: Int) { - precondition(!y.isZero) - assert(y.leadingZeroBitCount == 0) - if y.count == 1 { - let remainder = self.divide(byWord: y[0] >> shift) - self.load(BigUInt(remainder)) - return - } - self <<= shift - if self >= y { - let dc = y.count - let d1 = y[dc - 1] - let d0 = y[dc - 2] - var product: BigUInt = 0 - for j in (dc ... self.count).reversed() { - let r2 = self[j] - let r1 = self[j - 1] - let r0 = self[j - 2] - let q = Word.approximateQuotient(dividing: (r2, r1, r0), by: (d1, d0)) - product.load(y) - product.multiply(byWord: q) - if product <= self.extract(j - dc ..< j + 1) { - self.subtract(product, shiftedBy: j - dc) - } - else { - self.add(y, shiftedBy: j - dc) - self.subtract(product, shiftedBy: j - dc) - } - } - } - self >>= shift - } - - - /// Divide this integer by `y` and return the resulting quotient and remainder. - /// - /// - Requires: `y > 0` - /// - Returns: `(quotient, remainder)` where `quotient = floor(self/y)`, `remainder = self - quotient * y` - /// - Complexity: O(count^2) - public func quotientAndRemainder(dividingBy y: BigUInt) -> (quotient: BigUInt, remainder: BigUInt) { - var x = self - var y = y - BigUInt.divide(&x, by: &y) - return (x, y) - } - - /// Divide `x` by `y` and return the quotient. - /// - /// - Note: Use `divided(by:)` if you also need the remainder. - public static func /(x: BigUInt, y: BigUInt) -> BigUInt { - return x.quotientAndRemainder(dividingBy: y).quotient - } - - /// Divide `x` by `y` and return the remainder. - /// - /// - Note: Use `divided(by:)` if you also need the remainder. - public static func %(x: BigUInt, y: BigUInt) -> BigUInt { - var x = x - let shift = y.leadingZeroBitCount - x.formRemainder(dividingBy: y << shift, normalizedBy: shift) - return x - } - - /// Divide `x` by `y` and store the quotient in `x`. - /// - /// - Note: Use `divided(by:)` if you also need the remainder. - public static func /=(x: inout BigUInt, y: BigUInt) { - var y = y - BigUInt.divide(&x, by: &y) - } - - /// Divide `x` by `y` and store the remainder in `x`. - /// - /// - Note: Use `divided(by:)` if you also need the remainder. - public static func %=(x: inout BigUInt, y: BigUInt) { - let shift = y.leadingZeroBitCount - x.formRemainder(dividingBy: y << shift, normalizedBy: shift) - } -} - -extension BigInt { - /// Divide this integer by `y` and return the resulting quotient and remainder. - /// - /// - Requires: `y > 0` - /// - Returns: `(quotient, remainder)` where `quotient = floor(self/y)`, `remainder = self - quotient * y` - /// - Complexity: O(count^2) - public func quotientAndRemainder(dividingBy y: BigInt) -> (quotient: BigInt, remainder: BigInt) { - var a = self.magnitude - var b = y.magnitude - BigUInt.divide(&a, by: &b) - return (BigInt(sign: self.sign == y.sign ? .plus : .minus, magnitude: a), - BigInt(sign: self.sign, magnitude: b)) - } - - /// Divide `a` by `b` and return the quotient. Traps if `b` is zero. - public static func /(a: BigInt, b: BigInt) -> BigInt { - return BigInt(sign: a.sign == b.sign ? .plus : .minus, magnitude: a.magnitude / b.magnitude) - } - - /// Divide `a` by `b` and return the remainder. The result has the same sign as `a`. - public static func %(a: BigInt, b: BigInt) -> BigInt { - return BigInt(sign: a.sign, magnitude: a.magnitude % b.magnitude) - } - - /// Return the result of `a` mod `b`. The result is always a nonnegative integer that is less than the absolute value of `b`. - public func modulus(_ mod: BigInt) -> BigInt { - let remainder = self.magnitude % mod.magnitude - return BigInt( - self.sign == .minus && !remainder.isZero - ? mod.magnitude - remainder - : remainder) - } -} - -extension BigInt { - /// Divide `a` by `b` storing the quotient in `a`. - public static func /=(a: inout BigInt, b: BigInt) { a = a / b } - /// Divide `a` by `b` storing the remainder in `a`. - public static func %=(a: inout BigInt, b: BigInt) { a = a % b } -} diff --git a/Carthage/Checkouts/BigInt/Sources/Exponentiation.swift b/Carthage/Checkouts/BigInt/Sources/Exponentiation.swift deleted file mode 100644 index 9d7ee85da..000000000 --- a/Carthage/Checkouts/BigInt/Sources/Exponentiation.swift +++ /dev/null @@ -1,119 +0,0 @@ -// -// Exponentiation.swift -// BigInt -// -// Created by Károly Lőrentey on 2016-01-03. -// Copyright © 2016-2017 Károly Lőrentey. -// - -extension BigUInt { - //MARK: Exponentiation - - /// Returns this integer raised to the power `exponent`. - /// - /// This function calculates the result by [successively squaring the base while halving the exponent][expsqr]. - /// - /// [expsqr]: https://en.wikipedia.org/wiki/Exponentiation_by_squaring - /// - /// - Note: This function can be unreasonably expensive for large exponents, which is why `exponent` is - /// a simple integer value. If you want to calculate big exponents, you'll probably need to use - /// the modulo arithmetic variant. - /// - Returns: 1 if `exponent == 0`, otherwise `self` raised to `exponent`. (This implies that `0.power(0) == 1`.) - /// - SeeAlso: `BigUInt.power(_:, modulus:)` - /// - Complexity: O((exponent * self.count)^log2(3)) or somesuch. The result may require a large amount of memory, too. - public func power(_ exponent: Int) -> BigUInt { - if exponent == 0 { return 1 } - if exponent == 1 { return self } - if exponent < 0 { - precondition(!self.isZero) - return self == 1 ? 1 : 0 - } - if self <= 1 { return self } - var result = BigUInt(1) - var b = self - var e = exponent - while e > 0 { - if e & 1 == 1 { - result *= b - } - e >>= 1 - b *= b - } - return result - } - - /// Returns the remainder of this integer raised to the power `exponent` in modulo arithmetic under `modulus`. - /// - /// Uses the [right-to-left binary method][rtlb]. - /// - /// [rtlb]: https://en.wikipedia.org/wiki/Modular_exponentiation#Right-to-left_binary_method - /// - /// - Complexity: O(exponent.count * modulus.count^log2(3)) or somesuch - public func power(_ exponent: BigUInt, modulus: BigUInt) -> BigUInt { - precondition(!modulus.isZero) - if modulus == (1 as BigUInt) { return 0 } - let shift = modulus.leadingZeroBitCount - let normalizedModulus = modulus << shift - var result = BigUInt(1) - var b = self - b.formRemainder(dividingBy: normalizedModulus, normalizedBy: shift) - for var e in exponent.words { - for _ in 0 ..< Word.bitWidth { - if e & 1 == 1 { - result *= b - result.formRemainder(dividingBy: normalizedModulus, normalizedBy: shift) - } - e >>= 1 - b *= b - b.formRemainder(dividingBy: normalizedModulus, normalizedBy: shift) - } - } - return result - } -} - -extension BigInt { - /// Returns this integer raised to the power `exponent`. - /// - /// This function calculates the result by [successively squaring the base while halving the exponent][expsqr]. - /// - /// [expsqr]: https://en.wikipedia.org/wiki/Exponentiation_by_squaring - /// - /// - Note: This function can be unreasonably expensive for large exponents, which is why `exponent` is - /// a simple integer value. If you want to calculate big exponents, you'll probably need to use - /// the modulo arithmetic variant. - /// - Returns: 1 if `exponent == 0`, otherwise `self` raised to `exponent`. (This implies that `0.power(0) == 1`.) - /// - SeeAlso: `BigUInt.power(_:, modulus:)` - /// - Complexity: O((exponent * self.count)^log2(3)) or somesuch. The result may require a large amount of memory, too. - public func power(_ exponent: Int) -> BigInt { - return BigInt(sign: self.sign == .minus && exponent & 1 != 0 ? .minus : .plus, - magnitude: self.magnitude.power(exponent)) - } - - /// Returns the remainder of this integer raised to the power `exponent` in modulo arithmetic under `modulus`. - /// - /// Uses the [right-to-left binary method][rtlb]. - /// - /// [rtlb]: https://en.wikipedia.org/wiki/Modular_exponentiation#Right-to-left_binary_method - /// - /// - Complexity: O(exponent.count * modulus.count^log2(3)) or somesuch - public func power(_ exponent: BigInt, modulus: BigInt) -> BigInt { - precondition(!modulus.isZero) - if modulus.magnitude == 1 { return 0 } - if exponent.isZero { return 1 } - if exponent == 1 { return self.modulus(modulus) } - if exponent < 0 { - precondition(!self.isZero) - guard magnitude == 1 else { return 0 } - guard sign == .minus else { return 1 } - guard exponent.magnitude[0] & 1 != 0 else { return 1 } - return BigInt(modulus.magnitude - 1) - } - let power = self.magnitude.power(exponent.magnitude, - modulus: modulus.magnitude) - if self.sign == .plus || exponent.magnitude[0] & 1 == 0 || power.isZero { - return BigInt(power) - } - return BigInt(modulus.magnitude - power) - } -} diff --git a/Carthage/Checkouts/BigInt/Sources/Floating Point Conversion.swift b/Carthage/Checkouts/BigInt/Sources/Floating Point Conversion.swift deleted file mode 100644 index 6c2395a31..000000000 --- a/Carthage/Checkouts/BigInt/Sources/Floating Point Conversion.swift +++ /dev/null @@ -1,73 +0,0 @@ -// -// Floating Point Conversion.swift -// BigInt -// -// Created by Károly Lőrentey on 2017-08-11. -// Copyright © 2016-2017 Károly Lőrentey. -// - -extension BigUInt { - public init?(exactly source: T) { - guard source.isFinite else { return nil } - guard !source.isZero else { self = 0; return } - guard source.sign == .plus else { return nil } - let value = source.rounded(.towardZero) - guard value == source else { return nil } - assert(value.floatingPointClass == .positiveNormal) - assert(value.exponent >= 0) - let significand = value.significandBitPattern - self = (BigUInt(1) << value.exponent) + BigUInt(significand) >> (T.significandBitCount - Int(value.exponent)) - } - - public init(_ source: T) { - self.init(exactly: source.rounded(.towardZero))! - } -} - -extension BigInt { - public init?(exactly source: T) { - switch source.sign{ - case .plus: - guard let magnitude = BigUInt(exactly: source) else { return nil } - self = BigInt(sign: .plus, magnitude: magnitude) - case .minus: - guard let magnitude = BigUInt(exactly: -source) else { return nil } - self = BigInt(sign: .minus, magnitude: magnitude) - } - } - - public init(_ source: T) { - self.init(exactly: source.rounded(.towardZero))! - } -} - -extension BinaryFloatingPoint where RawExponent: FixedWidthInteger, RawSignificand: FixedWidthInteger { - public init(_ value: BigInt) { - guard !value.isZero else { self = 0; return } - let v = value.magnitude - let bitWidth = v.bitWidth - var exponent = bitWidth - 1 - let shift = bitWidth - Self.significandBitCount - 1 - var significand = value.magnitude >> (shift - 1) - if significand[0] & 3 == 3 { // Handle rounding - significand >>= 1 - significand += 1 - if significand.trailingZeroBitCount >= Self.significandBitCount { - exponent += 1 - } - } - else { - significand >>= 1 - } - let bias = 1 << (Self.exponentBitCount - 1) - 1 - guard exponent <= bias else { self = Self.infinity; return } - significand &= 1 << Self.significandBitCount - 1 - self = Self.init(sign: value.sign == .plus ? .plus : .minus, - exponentBitPattern: RawExponent(bias + exponent), - significandBitPattern: RawSignificand(significand)) - } - - public init(_ value: BigUInt) { - self.init(BigInt(sign: .plus, magnitude: value)) - } -} diff --git a/Carthage/Checkouts/BigInt/Sources/GCD.swift b/Carthage/Checkouts/BigInt/Sources/GCD.swift deleted file mode 100644 index d55605dce..000000000 --- a/Carthage/Checkouts/BigInt/Sources/GCD.swift +++ /dev/null @@ -1,80 +0,0 @@ -// -// GCD.swift -// BigInt -// -// Created by Károly Lőrentey on 2016-01-03. -// Copyright © 2016-2017 Károly Lőrentey. -// - -extension BigUInt { - //MARK: Greatest Common Divisor - - /// Returns the greatest common divisor of `self` and `b`. - /// - /// - Complexity: O(count^2) where count = max(self.count, b.count) - public func greatestCommonDivisor(with b: BigUInt) -> BigUInt { - // This is Stein's algorithm: https://en.wikipedia.org/wiki/Binary_GCD_algorithm - if self.isZero { return b } - if b.isZero { return self } - - let az = self.trailingZeroBitCount - let bz = b.trailingZeroBitCount - let twos = Swift.min(az, bz) - - var (x, y) = (self >> az, b >> bz) - if x < y { swap(&x, &y) } - - while !x.isZero { - x >>= x.trailingZeroBitCount - if x < y { swap(&x, &y) } - x -= y - } - return y << twos - } - - /// Returns the [multiplicative inverse of this integer in modulo `modulus` arithmetic][inverse], - /// or `nil` if there is no such number. - /// - /// [inverse]: https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm#Modular_integers - /// - /// - Returns: If `gcd(self, modulus) == 1`, the value returned is an integer `a < modulus` such that `(a * self) % modulus == 1`. If `self` and `modulus` aren't coprime, the return value is `nil`. - /// - Requires: modulus > 1 - /// - Complexity: O(count^3) - public func inverse(_ modulus: BigUInt) -> BigUInt? { - precondition(modulus > 1) - var t1 = BigInt(0) - var t2 = BigInt(1) - var r1 = modulus - var r2 = self - while !r2.isZero { - let quotient = r1 / r2 - (t1, t2) = (t2, t1 - BigInt(quotient) * t2) - (r1, r2) = (r2, r1 - quotient * r2) - } - if r1 > 1 { return nil } - if t1.sign == .minus { return modulus - t1.magnitude } - return t1.magnitude - } -} - -extension BigInt { - /// Returns the greatest common divisor of `a` and `b`. - /// - /// - Complexity: O(count^2) where count = max(a.count, b.count) - public func greatestCommonDivisor(with b: BigInt) -> BigInt { - return BigInt(self.magnitude.greatestCommonDivisor(with: b.magnitude)) - } - - /// Returns the [multiplicative inverse of this integer in modulo `modulus` arithmetic][inverse], - /// or `nil` if there is no such number. - /// - /// [inverse]: https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm#Modular_integers - /// - /// - Returns: If `gcd(self, modulus) == 1`, the value returned is an integer `a < modulus` such that `(a * self) % modulus == 1`. If `self` and `modulus` aren't coprime, the return value is `nil`. - /// - Requires: modulus.magnitude > 1 - /// - Complexity: O(count^3) - public func inverse(_ modulus: BigInt) -> BigInt? { - guard let inv = self.magnitude.inverse(modulus.magnitude) else { return nil } - return BigInt(self.sign == .plus || inv.isZero ? inv : modulus.magnitude - inv) - } -} diff --git a/Carthage/Checkouts/BigInt/Sources/Hashable.swift b/Carthage/Checkouts/BigInt/Sources/Hashable.swift deleted file mode 100644 index c5dc0e642..000000000 --- a/Carthage/Checkouts/BigInt/Sources/Hashable.swift +++ /dev/null @@ -1,26 +0,0 @@ -// -// Hashable.swift -// BigInt -// -// Created by Károly Lőrentey on 2016-01-03. -// Copyright © 2016-2017 Károly Lőrentey. -// - -extension BigUInt: Hashable { - //MARK: Hashing - - /// Append this `BigUInt` to the specified hasher. - public func hash(into hasher: inout Hasher) { - for word in self.words { - hasher.combine(word) - } - } -} - -extension BigInt: Hashable { - /// Append this `BigInt` to the specified hasher. - public func hash(into hasher: inout Hasher) { - hasher.combine(sign) - hasher.combine(magnitude) - } -} diff --git a/Carthage/Checkouts/BigInt/Sources/Info.plist b/Carthage/Checkouts/BigInt/Sources/Info.plist deleted file mode 100644 index 63135fb1e..000000000 --- a/Carthage/Checkouts/BigInt/Sources/Info.plist +++ /dev/null @@ -1,28 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - FMWK - CFBundleShortVersionString - $(VERSION_STRING) - CFBundleSignature - ???? - CFBundleVersion - $(CURRENT_PROJECT_VERSION) - NSPrincipalClass - - NSHumanReadableCopyright - Copyright © 2016 Károly Lőrentey. - - diff --git a/Carthage/Checkouts/BigInt/Sources/Integer Conversion.swift b/Carthage/Checkouts/BigInt/Sources/Integer Conversion.swift deleted file mode 100644 index 9a210e4a4..000000000 --- a/Carthage/Checkouts/BigInt/Sources/Integer Conversion.swift +++ /dev/null @@ -1,89 +0,0 @@ -// -// Integer Conversion.swift -// BigInt -// -// Created by Károly Lőrentey on 2017-08-11. -// Copyright © 2016-2017 Károly Lőrentey. -// - -extension BigUInt { - public init?(exactly source: T) { - guard source >= (0 as T) else { return nil } - if source.bitWidth <= 2 * Word.bitWidth { - var it = source.words.makeIterator() - self.init(low: it.next() ?? 0, high: it.next() ?? 0) - precondition(it.next() == nil, "Length of BinaryInteger.words is greater than its bitWidth") - } - else { - self.init(words: source.words) - } - } - - public init(_ source: T) { - precondition(source >= (0 as T), "BigUInt cannot represent negative values") - self.init(exactly: source)! - } - - public init(truncatingIfNeeded source: T) { - self.init(words: source.words) - } - - public init(clamping source: T) { - if source <= (0 as T) { - self.init() - } - else { - self.init(words: source.words) - } - } -} - -extension BigInt { - public init() { - self.init(sign: .plus, magnitude: 0) - } - - /// Initializes a new signed big integer with the same value as the specified unsigned big integer. - public init(_ integer: BigUInt) { - self.magnitude = integer - self.sign = .plus - } - - public init(_ source: T) where T : BinaryInteger { - if source >= (0 as T) { - self.init(sign: .plus, magnitude: BigUInt(source)) - } - else { - var words = Array(source.words) - words.twosComplement() - self.init(sign: .minus, magnitude: BigUInt(words: words)) - } - } - - public init?(exactly source: T) where T : BinaryInteger { - self.init(source) - } - - public init(clamping source: T) where T : BinaryInteger { - self.init(source) - } - - public init(truncatingIfNeeded source: T) where T : BinaryInteger { - self.init(source) - } -} - -extension BigUInt: ExpressibleByIntegerLiteral { - /// Initialize a new big integer from an integer literal. - public init(integerLiteral value: UInt64) { - self.init(value) - } -} - -extension BigInt: ExpressibleByIntegerLiteral { - /// Initialize a new big integer from an integer literal. - public init(integerLiteral value: Int64) { - self.init(value) - } -} - diff --git a/Carthage/Checkouts/BigInt/Sources/Multiplication.swift b/Carthage/Checkouts/BigInt/Sources/Multiplication.swift deleted file mode 100644 index 635c36a5f..000000000 --- a/Carthage/Checkouts/BigInt/Sources/Multiplication.swift +++ /dev/null @@ -1,165 +0,0 @@ -// -// Multiplication.swift -// BigInt -// -// Created by Károly Lőrentey on 2016-01-03. -// Copyright © 2016-2017 Károly Lőrentey. -// - -extension BigUInt { - - //MARK: Multiplication - - /// Multiply this big integer by a single word, and store the result in place of the original big integer. - /// - /// - Complexity: O(count) - public mutating func multiply(byWord y: Word) { - guard y != 0 else { self = 0; return } - guard y != 1 else { return } - var carry: Word = 0 - let c = self.count - for i in 0 ..< c { - let (h, l) = self[i].multipliedFullWidth(by: y) - let (low, o) = l.addingReportingOverflow(carry) - self[i] = low - carry = (o ? h + 1 : h) - } - self[c] = carry - } - - /// Multiply this big integer by a single Word, and return the result. - /// - /// - Complexity: O(count) - public func multiplied(byWord y: Word) -> BigUInt { - var r = self - r.multiply(byWord: y) - return r - } - - /// Multiply `x` by `y`, and add the result to this integer, optionally shifted `shift` words to the left. - /// - /// - Note: This is the fused multiply/shift/add operation; it is more efficient than doing the components - /// individually. (The fused operation doesn't need to allocate space for temporary big integers.) - /// - Returns: `self` is set to `self + (x * y) << (shift * 2^Word.bitWidth)` - /// - Complexity: O(count) - public mutating func multiplyAndAdd(_ x: BigUInt, _ y: Word, shiftedBy shift: Int = 0) { - precondition(shift >= 0) - guard y != 0 && x.count > 0 else { return } - guard y != 1 else { self.add(x, shiftedBy: shift); return } - var mulCarry: Word = 0 - var addCarry = false - let xc = x.count - var xi = 0 - while xi < xc || addCarry || mulCarry > 0 { - let (h, l) = x[xi].multipliedFullWidth(by: y) - let (low, o) = l.addingReportingOverflow(mulCarry) - mulCarry = (o ? h + 1 : h) - - let ai = shift + xi - let (sum1, so1) = self[ai].addingReportingOverflow(low) - if addCarry { - let (sum2, so2) = sum1.addingReportingOverflow(1) - self[ai] = sum2 - addCarry = so1 || so2 - } - else { - self[ai] = sum1 - addCarry = so1 - } - xi += 1 - } - } - - /// Multiply this integer by `y` and return the result. - /// - /// - Note: This uses the naive O(n^2) multiplication algorithm unless both arguments have more than - /// `BigUInt.directMultiplicationLimit` words. - /// - Complexity: O(n^log2(3)) - public func multiplied(by y: BigUInt) -> BigUInt { - // This method is mostly defined for symmetry with the rest of the arithmetic operations. - return self * y - } - - /// Multiplication switches to an asymptotically better recursive algorithm when arguments have more words than this limit. - public static var directMultiplicationLimit: Int = 1024 - - /// Multiply `a` by `b` and return the result. - /// - /// - Note: This uses the naive O(n^2) multiplication algorithm unless both arguments have more than - /// `BigUInt.directMultiplicationLimit` words. - /// - Complexity: O(n^log2(3)) - public static func *(x: BigUInt, y: BigUInt) -> BigUInt { - let xc = x.count - let yc = y.count - if xc == 0 { return BigUInt() } - if yc == 0 { return BigUInt() } - if yc == 1 { return x.multiplied(byWord: y[0]) } - if xc == 1 { return y.multiplied(byWord: x[0]) } - - if Swift.min(xc, yc) <= BigUInt.directMultiplicationLimit { - // Long multiplication. - let left = (xc < yc ? y : x) - let right = (xc < yc ? x : y) - var result = BigUInt() - for i in (0 ..< right.count).reversed() { - result.multiplyAndAdd(left, right[i], shiftedBy: i) - } - return result - } - - if yc < xc { - let (xh, xl) = x.split - var r = xl * y - r.add(xh * y, shiftedBy: x.middleIndex) - return r - } - else if xc < yc { - let (yh, yl) = y.split - var r = yl * x - r.add(yh * x, shiftedBy: y.middleIndex) - return r - } - - let shift = x.middleIndex - - // Karatsuba multiplication: - // x * y = * = (ignoring carry) - let (a, b) = x.split - let (c, d) = y.split - - let high = a * c - let low = b * d - let xp = a >= b - let yp = c >= d - let xm = (xp ? a - b : b - a) - let ym = (yp ? c - d : d - c) - let m = xm * ym - - var r = low - r.add(high, shiftedBy: 2 * shift) - r.add(low, shiftedBy: shift) - r.add(high, shiftedBy: shift) - if xp == yp { - r.subtract(m, shiftedBy: shift) - } - else { - r.add(m, shiftedBy: shift) - } - return r - } - - /// Multiply `a` by `b` and store the result in `a`. - public static func *=(a: inout BigUInt, b: BigUInt) { - a = a * b - } -} - -extension BigInt { - /// Multiply `a` with `b` and return the result. - public static func *(a: BigInt, b: BigInt) -> BigInt { - return BigInt(sign: a.sign == b.sign ? .plus : .minus, magnitude: a.magnitude * b.magnitude) - } - - /// Multiply `a` with `b` in place. - public static func *=(a: inout BigInt, b: BigInt) { a = a * b } -} diff --git a/Carthage/Checkouts/BigInt/Sources/Prime Test.swift b/Carthage/Checkouts/BigInt/Sources/Prime Test.swift deleted file mode 100644 index 7f1871104..000000000 --- a/Carthage/Checkouts/BigInt/Sources/Prime Test.swift +++ /dev/null @@ -1,153 +0,0 @@ -// -// Prime Test.swift -// BigInt -// -// Created by Károly Lőrentey on 2016-01-04. -// Copyright © 2016-2017 Károly Lőrentey. -// - -/// The first several [prime numbers][primes]. -/// -/// [primes]: https://oeis.org/A000040 -let primes: [BigUInt.Word] = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41] - -/// The ith element in this sequence is the smallest composite number that passes the strong probable prime test -/// for all of the first (i+1) primes. -/// -/// This is sequence [A014233](http://oeis.org/A014233) on the [Online Encyclopaedia of Integer Sequences](http://oeis.org). -let pseudoPrimes: [BigUInt] = [ - /* 2 */ 2_047, - /* 3 */ 1_373_653, - /* 5 */ 25_326_001, - /* 7 */ 3_215_031_751, - /* 11 */ 2_152_302_898_747, - /* 13 */ 3_474_749_660_383, - /* 17 */ 341_550_071_728_321, - /* 19 */ 341_550_071_728_321, - /* 23 */ 3_825_123_056_546_413_051, - /* 29 */ 3_825_123_056_546_413_051, - /* 31 */ 3_825_123_056_546_413_051, - /* 37 */ "318665857834031151167461", - /* 41 */ "3317044064679887385961981", -] - -extension BigUInt { - //MARK: Primality Testing - - /// Returns true iff this integer passes the [strong probable prime test][sppt] for the specified base. - /// - /// [sppt]: https://en.wikipedia.org/wiki/Probable_prime - public func isStrongProbablePrime(_ base: BigUInt) -> Bool { - precondition(base > (1 as BigUInt)) - precondition(self > (0 as BigUInt)) - let dec = self - 1 - - let r = dec.trailingZeroBitCount - let d = dec >> r - - var test = base.power(d, modulus: self) - if test == 1 || test == dec { return true } - - if r > 0 { - let shift = self.leadingZeroBitCount - let normalized = self << shift - for _ in 1 ..< r { - test *= test - test.formRemainder(dividingBy: normalized, normalizedBy: shift) - if test == 1 { - return false - } - if test == dec { return true } - } - } - return false - } - - /// Returns true if this integer is probably prime. Returns false if this integer is definitely not prime. - /// - /// This function performs a probabilistic [Miller-Rabin Primality Test][mrpt], consisting of `rounds` iterations, - /// each calculating the strong probable prime test for a random base. The number of rounds is 10 by default, - /// but you may specify your own choice. - /// - /// To speed things up, the function checks if `self` is divisible by the first few prime numbers before - /// diving into (slower) Miller-Rabin testing. - /// - /// Also, when `self` is less than 82 bits wide, `isPrime` does a deterministic test that is guaranteed to - /// return a correct result. - /// - /// [mrpt]: https://en.wikipedia.org/wiki/Miller–Rabin_primality_test - public func isPrime(rounds: Int = 10) -> Bool { - if count <= 1 && self[0] < 2 { return false } - if count == 1 && self[0] < 4 { return true } - - // Even numbers above 2 aren't prime. - if self[0] & 1 == 0 { return false } - - // Quickly check for small primes. - for i in 1 ..< primes.count { - let p = primes[i] - if self.count == 1 && self[0] == p { - return true - } - if self.quotientAndRemainder(dividingByWord: p).remainder == 0 { - return false - } - } - - /// Give an exact answer when we can. - if self < pseudoPrimes.last! { - for i in 0 ..< pseudoPrimes.count { - guard isStrongProbablePrime(BigUInt(primes[i])) else { - break - } - if self < pseudoPrimes[i] { - // `self` is below the lowest pseudoprime corresponding to the prime bases we tested. It's a prime! - return true - } - } - return false - } - - /// Otherwise do as many rounds of random SPPT as required. - for _ in 0 ..< rounds { - let random = BigUInt.randomInteger(lessThan: self - 2) + 2 - guard isStrongProbablePrime(random) else { - return false - } - } - - // Well, it smells primey to me. - return true - } -} - -extension BigInt { - //MARK: Primality Testing - - /// Returns true iff this integer passes the [strong probable prime test][sppt] for the specified base. - /// - /// [sppt]: https://en.wikipedia.org/wiki/Probable_prime - public func isStrongProbablePrime(_ base: BigInt) -> Bool { - precondition(base.sign == .plus) - if self.sign == .minus { return false } - return self.magnitude.isStrongProbablePrime(base.magnitude) - } - - /// Returns true if this integer is probably prime. Returns false if this integer is definitely not prime. - /// - /// This function performs a probabilistic [Miller-Rabin Primality Test][mrpt], consisting of `rounds` iterations, - /// each calculating the strong probable prime test for a random base. The number of rounds is 10 by default, - /// but you may specify your own choice. - /// - /// To speed things up, the function checks if `self` is divisible by the first few prime numbers before - /// diving into (slower) Miller-Rabin testing. - /// - /// Also, when `self` is less than 82 bits wide, `isPrime` does a deterministic test that is guaranteed to - /// return a correct result. - /// - /// [mrpt]: https://en.wikipedia.org/wiki/Miller–Rabin_primality_test - public func isPrime(rounds: Int = 10) -> Bool { - if self.sign == .minus { return false } - return self.magnitude.isPrime(rounds: rounds) - } -} diff --git a/Carthage/Checkouts/BigInt/Sources/Random.swift b/Carthage/Checkouts/BigInt/Sources/Random.swift deleted file mode 100644 index bea98caf0..000000000 --- a/Carthage/Checkouts/BigInt/Sources/Random.swift +++ /dev/null @@ -1,101 +0,0 @@ -// -// Random.swift -// BigInt -// -// Created by Károly Lőrentey on 2016-01-04. -// Copyright © 2016-2017 Károly Lőrentey. -// - -extension BigUInt { - /// Create a big unsigned integer consisting of `width` uniformly distributed random bits. - /// - /// - Parameter width: The maximum number of one bits in the result. - /// - Parameter generator: The source of randomness. - /// - Returns: A big unsigned integer less than `1 << width`. - public static func randomInteger(withMaximumWidth width: Int, using generator: inout RNG) -> BigUInt { - var result = BigUInt.zero - var bitsLeft = width - var i = 0 - let wordsNeeded = (width + Word.bitWidth - 1) / Word.bitWidth - if wordsNeeded > 2 { - result.reserveCapacity(wordsNeeded) - } - while bitsLeft >= Word.bitWidth { - result[i] = generator.next() - i += 1 - bitsLeft -= Word.bitWidth - } - if bitsLeft > 0 { - let mask: Word = (1 << bitsLeft) - 1 - result[i] = (generator.next() as Word) & mask - } - return result - } - - /// Create a big unsigned integer consisting of `width` uniformly distributed random bits. - /// - /// - Note: I use a `SystemRandomGeneratorGenerator` as the source of randomness. - /// - /// - Parameter width: The maximum number of one bits in the result. - /// - Returns: A big unsigned integer less than `1 << width`. - public static func randomInteger(withMaximumWidth width: Int) -> BigUInt { - var rng = SystemRandomNumberGenerator() - return randomInteger(withMaximumWidth: width, using: &rng) - } - - /// Create a big unsigned integer consisting of `width-1` uniformly distributed random bits followed by a one bit. - /// - /// - Note: If `width` is zero, the result is zero. - /// - /// - Parameter width: The number of bits required to represent the answer. - /// - Parameter generator: The source of randomness. - /// - Returns: A random big unsigned integer whose width is `width`. - public static func randomInteger(withExactWidth width: Int, using generator: inout RNG) -> BigUInt { - // width == 0 -> return 0 because there is no room for a one bit. - // width == 1 -> return 1 because there is no room for any random bits. - guard width > 1 else { return BigUInt(width) } - var result = randomInteger(withMaximumWidth: width - 1, using: &generator) - result[(width - 1) / Word.bitWidth] |= 1 << Word((width - 1) % Word.bitWidth) - return result - } - - /// Create a big unsigned integer consisting of `width-1` uniformly distributed random bits followed by a one bit. - /// - /// - Note: If `width` is zero, the result is zero. - /// - Note: I use a `SystemRandomGeneratorGenerator` as the source of randomness. - /// - /// - Returns: A random big unsigned integer whose width is `width`. - public static func randomInteger(withExactWidth width: Int) -> BigUInt { - var rng = SystemRandomNumberGenerator() - return randomInteger(withExactWidth: width, using: &rng) - } - - /// Create a uniformly distributed random unsigned integer that's less than the specified limit. - /// - /// - Precondition: `limit > 0`. - /// - /// - Parameter limit: The upper bound on the result. - /// - Parameter generator: The source of randomness. - /// - Returns: A random big unsigned integer that is less than `limit`. - public static func randomInteger(lessThan limit: BigUInt, using generator: inout RNG) -> BigUInt { - precondition(limit > 0, "\(#function): 0 is not a valid limit") - let width = limit.bitWidth - var random = randomInteger(withMaximumWidth: width, using: &generator) - while random >= limit { - random = randomInteger(withMaximumWidth: width, using: &generator) - } - return random - } - - /// Create a uniformly distributed random unsigned integer that's less than the specified limit. - /// - /// - Precondition: `limit > 0`. - /// - Note: I use a `SystemRandomGeneratorGenerator` as the source of randomness. - /// - /// - Parameter limit: The upper bound on the result. - /// - Returns: A random big unsigned integer that is less than `limit`. - public static func randomInteger(lessThan limit: BigUInt) -> BigUInt { - var rng = SystemRandomNumberGenerator() - return randomInteger(lessThan: limit, using: &rng) - } -} diff --git a/Carthage/Checkouts/BigInt/Sources/Shifts.swift b/Carthage/Checkouts/BigInt/Sources/Shifts.swift deleted file mode 100644 index e676e4143..000000000 --- a/Carthage/Checkouts/BigInt/Sources/Shifts.swift +++ /dev/null @@ -1,211 +0,0 @@ -// -// Shifts.swift -// BigInt -// -// Created by Károly Lőrentey on 2016-01-03. -// Copyright © 2016-2017 Károly Lőrentey. -// - -extension BigUInt { - - //MARK: Shift Operators - - internal func shiftedLeft(by amount: Word) -> BigUInt { - guard amount > 0 else { return self } - - let ext = Int(amount / Word(Word.bitWidth)) // External shift amount (new words) - let up = Word(amount % Word(Word.bitWidth)) // Internal shift amount (subword shift) - let down = Word(Word.bitWidth) - up - - var result = BigUInt() - if up > 0 { - var i = 0 - var lowbits: Word = 0 - while i < self.count || lowbits > 0 { - let word = self[i] - result[i + ext] = word << up | lowbits - lowbits = word >> down - i += 1 - } - } - else { - for i in 0 ..< self.count { - result[i + ext] = self[i] - } - } - return result - } - - internal mutating func shiftLeft(by amount: Word) { - guard amount > 0 else { return } - - let ext = Int(amount / Word(Word.bitWidth)) // External shift amount (new words) - let up = Word(amount % Word(Word.bitWidth)) // Internal shift amount (subword shift) - let down = Word(Word.bitWidth) - up - - if up > 0 { - var i = 0 - var lowbits: Word = 0 - while i < self.count || lowbits > 0 { - let word = self[i] - self[i] = word << up | lowbits - lowbits = word >> down - i += 1 - } - } - if ext > 0 && self.count > 0 { - self.shiftLeft(byWords: ext) - } - } - - internal func shiftedRight(by amount: Word) -> BigUInt { - guard amount > 0 else { return self } - guard amount < self.bitWidth else { return 0 } - - let ext = Int(amount / Word(Word.bitWidth)) // External shift amount (new words) - let down = Word(amount % Word(Word.bitWidth)) // Internal shift amount (subword shift) - let up = Word(Word.bitWidth) - down - - var result = BigUInt() - if down > 0 { - var highbits: Word = 0 - for i in (ext ..< self.count).reversed() { - let word = self[i] - result[i - ext] = highbits | word >> down - highbits = word << up - } - } - else { - for i in (ext ..< self.count).reversed() { - result[i - ext] = self[i] - } - } - return result - } - - internal mutating func shiftRight(by amount: Word) { - guard amount > 0 else { return } - guard amount < self.bitWidth else { self.clear(); return } - - let ext = Int(amount / Word(Word.bitWidth)) // External shift amount (new words) - let down = Word(amount % Word(Word.bitWidth)) // Internal shift amount (subword shift) - let up = Word(Word.bitWidth) - down - - if ext > 0 { - self.shiftRight(byWords: ext) - } - if down > 0 { - var i = self.count - 1 - var highbits: Word = 0 - while i >= 0 { - let word = self[i] - self[i] = highbits | word >> down - highbits = word << up - i -= 1 - } - } - } - - public static func >>=(lhs: inout BigUInt, rhs: Other) { - if rhs < (0 as Other) { - lhs <<= (0 - rhs) - } - else if rhs >= lhs.bitWidth { - lhs.clear() - } - else { - lhs.shiftRight(by: UInt(rhs)) - } - } - - public static func <<=(lhs: inout BigUInt, rhs: Other) { - if rhs < (0 as Other) { - lhs >>= (0 - rhs) - return - } - lhs.shiftLeft(by: Word(exactly: rhs)!) - } - - public static func >>(lhs: BigUInt, rhs: Other) -> BigUInt { - if rhs < (0 as Other) { - return lhs << (0 - rhs) - } - if rhs > Word.max { - return 0 - } - return lhs.shiftedRight(by: UInt(rhs)) - } - - public static func <<(lhs: BigUInt, rhs: Other) -> BigUInt { - if rhs < (0 as Other) { - return lhs >> (0 - rhs) - } - return lhs.shiftedLeft(by: Word(exactly: rhs)!) - } -} - -extension BigInt { - func shiftedLeft(by amount: Word) -> BigInt { - return BigInt(sign: self.sign, magnitude: self.magnitude.shiftedLeft(by: amount)) - } - - mutating func shiftLeft(by amount: Word) { - self.magnitude.shiftLeft(by: amount) - } - - func shiftedRight(by amount: Word) -> BigInt { - let m = self.magnitude.shiftedRight(by: amount) - return BigInt(sign: self.sign, magnitude: self.sign == .minus && m.isZero ? 1 : m) - } - - mutating func shiftRight(by amount: Word) { - magnitude.shiftRight(by: amount) - if sign == .minus, magnitude.isZero { - magnitude.load(1) - } - } - - public static func &<<(left: BigInt, right: BigInt) -> BigInt { - return left.shiftedLeft(by: right.words[0]) - } - - public static func &<<=(left: inout BigInt, right: BigInt) { - left.shiftLeft(by: right.words[0]) - } - - public static func &>>(left: BigInt, right: BigInt) -> BigInt { - return left.shiftedRight(by: right.words[0]) - } - - public static func &>>=(left: inout BigInt, right: BigInt) { - left.shiftRight(by: right.words[0]) - } - - public static func <<(lhs: BigInt, rhs: Other) -> BigInt { - guard rhs >= (0 as Other) else { return lhs >> (0 - rhs) } - return lhs.shiftedLeft(by: Word(rhs)) - } - - public static func <<=(lhs: inout BigInt, rhs: Other) { - if rhs < (0 as Other) { - lhs >>= (0 - rhs) - } - else { - lhs.shiftLeft(by: Word(rhs)) - } - } - - public static func >>(lhs: BigInt, rhs: Other) -> BigInt { - guard rhs >= (0 as Other) else { return lhs << (0 - rhs) } - return lhs.shiftedRight(by: Word(rhs)) - } - - public static func >>=(lhs: inout BigInt, rhs: Other) { - if rhs < (0 as Other) { - lhs <<= (0 - rhs) - } - else { - lhs.shiftRight(by: Word(rhs)) - } - } -} diff --git a/Carthage/Checkouts/BigInt/Sources/Square Root.swift b/Carthage/Checkouts/BigInt/Sources/Square Root.swift deleted file mode 100644 index 68db0691c..000000000 --- a/Carthage/Checkouts/BigInt/Sources/Square Root.swift +++ /dev/null @@ -1,41 +0,0 @@ -// -// Square Root.swift -// BigInt -// -// Created by Károly Lőrentey on 2016-01-03. -// Copyright © 2016-2017 Károly Lőrentey. -// - -//MARK: Square Root - -extension BigUInt { - /// Returns the integer square root of a big integer; i.e., the largest integer whose square isn't greater than `value`. - /// - /// - Returns: floor(sqrt(self)) - public func squareRoot() -> BigUInt { - // This implementation uses Newton's method. - guard !self.isZero else { return BigUInt() } - var x = BigUInt(1) << ((self.bitWidth + 1) / 2) - var y: BigUInt = 0 - while true { - y.load(self) - y /= x - y += x - y >>= 1 - if x == y || x == y - 1 { break } - x = y - } - return x - } -} - -extension BigInt { - /// Returns the integer square root of a big integer; i.e., the largest integer whose square isn't greater than `value`. - /// - /// - Requires: self >= 0 - /// - Returns: floor(sqrt(self)) - public func squareRoot() -> BigInt { - precondition(self.sign == .plus) - return BigInt(sign: .plus, magnitude: self.magnitude.squareRoot()) - } -} diff --git a/Carthage/Checkouts/BigInt/Sources/Strideable.swift b/Carthage/Checkouts/BigInt/Sources/Strideable.swift deleted file mode 100644 index 2b79babd1..000000000 --- a/Carthage/Checkouts/BigInt/Sources/Strideable.swift +++ /dev/null @@ -1,38 +0,0 @@ -// -// Strideable.swift -// BigInt -// -// Created by Károly Lőrentey on 2017-08-11. -// Copyright © 2016-2017 Károly Lőrentey. -// - -extension BigUInt: Strideable { - /// A type that can represent the distance between two values ofa `BigUInt`. - public typealias Stride = BigInt - - /// Adds `n` to `self` and returns the result. Traps if the result would be less than zero. - public func advanced(by n: BigInt) -> BigUInt { - return n.sign == .minus ? self - n.magnitude : self + n.magnitude - } - - /// Returns the (potentially negative) difference between `self` and `other` as a `BigInt`. Never traps. - public func distance(to other: BigUInt) -> BigInt { - return BigInt(other) - BigInt(self) - } -} - -extension BigInt: Strideable { - public typealias Stride = BigInt - - /// Returns `self + n`. - public func advanced(by n: Stride) -> BigInt { - return self + n - } - - /// Returns `other - self`. - public func distance(to other: BigInt) -> Stride { - return other - self - } -} - - diff --git a/Carthage/Checkouts/BigInt/Sources/String Conversion.swift b/Carthage/Checkouts/BigInt/Sources/String Conversion.swift deleted file mode 100644 index d6f340c93..000000000 --- a/Carthage/Checkouts/BigInt/Sources/String Conversion.swift +++ /dev/null @@ -1,236 +0,0 @@ -// -// String Conversion.swift -// BigInt -// -// Created by Károly Lőrentey on 2016-01-03. -// Copyright © 2016-2017 Károly Lőrentey. -// - -extension BigUInt { - - //MARK: String Conversion - - /// Calculates the number of numerals in a given radix that fit inside a single `Word`. - /// - /// - Returns: (chars, power) where `chars` is highest that satisfy `radix^chars <= 2^Word.bitWidth`. `power` is zero - /// if radix is a power of two; otherwise `power == radix^chars`. - fileprivate static func charsPerWord(forRadix radix: Int) -> (chars: Int, power: Word) { - var power: Word = 1 - var overflow = false - var count = 0 - while !overflow { - let (p, o) = power.multipliedReportingOverflow(by: Word(radix)) - overflow = o - if !o || p == 0 { - count += 1 - power = p - } - } - return (count, power) - } - - /// Initialize a big integer from an ASCII representation in a given radix. Numerals above `9` are represented by - /// letters from the English alphabet. - /// - /// - Requires: `radix > 1 && radix < 36` - /// - Parameter `text`: A string consisting of characters corresponding to numerals in the given radix. (0-9, a-z, A-Z) - /// - Parameter `radix`: The base of the number system to use, or 10 if unspecified. - /// - Returns: The integer represented by `text`, or nil if `text` contains a character that does not represent a numeral in `radix`. - public init?(_ text: S, radix: Int = 10) { - precondition(radix > 1) - let (charsPerWord, power) = BigUInt.charsPerWord(forRadix: radix) - - var words: [Word] = [] - var end = text.endIndex - var start = end - var count = 0 - while start != text.startIndex { - start = text.index(before: start) - count += 1 - if count == charsPerWord { - guard let d = Word.init(text[start ..< end], radix: radix) else { return nil } - words.append(d) - end = start - count = 0 - } - } - if start != end { - guard let d = Word.init(text[start ..< end], radix: radix) else { return nil } - words.append(d) - } - - if power == 0 { - self.init(words: words) - } - else { - self.init() - for d in words.reversed() { - self.multiply(byWord: power) - self.addWord(d) - } - } - } -} - -extension BigInt { - /// Initialize a big integer from an ASCII representation in a given radix. Numerals above `9` are represented by - /// letters from the English alphabet. - /// - /// - Requires: `radix > 1 && radix < 36` - /// - Parameter `text`: A string optionally starting with "-" or "+" followed by characters corresponding to numerals in the given radix. (0-9, a-z, A-Z) - /// - Parameter `radix`: The base of the number system to use, or 10 if unspecified. - /// - Returns: The integer represented by `text`, or nil if `text` contains a character that does not represent a numeral in `radix`. - public init?(_ text: S, radix: Int = 10) { - var magnitude: BigUInt? - var sign: Sign = .plus - if text.first == "-" { - sign = .minus - let text = text.dropFirst() - magnitude = BigUInt(text, radix: radix) - } - else if text.first == "+" { - let text = text.dropFirst() - magnitude = BigUInt(text, radix: radix) - } - else { - magnitude = BigUInt(text, radix: radix) - } - guard let m = magnitude else { return nil } - self.magnitude = m - self.sign = sign - } -} - -extension String { - /// Initialize a new string with the base-10 representation of an unsigned big integer. - /// - /// - Complexity: O(v.count^2) - public init(_ v: BigUInt) { self.init(v, radix: 10, uppercase: false) } - - /// Initialize a new string representing an unsigned big integer in the given radix (base). - /// - /// Numerals greater than 9 are represented as letters from the English alphabet, - /// starting with `a` if `uppercase` is false or `A` otherwise. - /// - /// - Requires: radix > 1 && radix <= 36 - /// - Complexity: O(count) when radix is a power of two; otherwise O(count^2). - public init(_ v: BigUInt, radix: Int, uppercase: Bool = false) { - precondition(radix > 1) - let (charsPerWord, power) = BigUInt.charsPerWord(forRadix: radix) - - guard !v.isZero else { self = "0"; return } - - var parts: [String] - if power == 0 { - parts = v.words.map { String($0, radix: radix, uppercase: uppercase) } - } - else { - parts = [] - var rest = v - while !rest.isZero { - let mod = rest.divide(byWord: power) - parts.append(String(mod, radix: radix, uppercase: uppercase)) - } - } - assert(!parts.isEmpty) - - self = "" - var first = true - for part in parts.reversed() { - let zeroes = charsPerWord - part.count - assert(zeroes >= 0) - if !first && zeroes > 0 { - // Insert leading zeroes for mid-Words - self += String(repeating: "0", count: zeroes) - } - first = false - self += part - } - } - - /// Initialize a new string representing a signed big integer in the given radix (base). - /// - /// Numerals greater than 9 are represented as letters from the English alphabet, - /// starting with `a` if `uppercase` is false or `A` otherwise. - /// - /// - Requires: radix > 1 && radix <= 36 - /// - Complexity: O(count) when radix is a power of two; otherwise O(count^2). - public init(_ value: BigInt, radix: Int = 10, uppercase: Bool = false) { - self = String(value.magnitude, radix: radix, uppercase: uppercase) - if value.sign == .minus { - self = "-" + self - } - } -} - -extension BigUInt: ExpressibleByStringLiteral { - /// Initialize a new big integer from a Unicode scalar. - /// The scalar must represent a decimal digit. - public init(unicodeScalarLiteral value: UnicodeScalar) { - self = BigUInt(String(value), radix: 10)! - } - - /// Initialize a new big integer from an extended grapheme cluster. - /// The cluster must consist of a decimal digit. - public init(extendedGraphemeClusterLiteral value: String) { - self = BigUInt(value, radix: 10)! - } - - /// Initialize a new big integer from a decimal number represented by a string literal of arbitrary length. - /// The string must contain only decimal digits. - public init(stringLiteral value: StringLiteralType) { - self = BigUInt(value, radix: 10)! - } -} - -extension BigInt: ExpressibleByStringLiteral { - /// Initialize a new big integer from a Unicode scalar. - /// The scalar must represent a decimal digit. - public init(unicodeScalarLiteral value: UnicodeScalar) { - self = BigInt(String(value), radix: 10)! - } - - /// Initialize a new big integer from an extended grapheme cluster. - /// The cluster must consist of a decimal digit. - public init(extendedGraphemeClusterLiteral value: String) { - self = BigInt(value, radix: 10)! - } - - /// Initialize a new big integer from a decimal number represented by a string literal of arbitrary length. - /// The string must contain only decimal digits. - public init(stringLiteral value: StringLiteralType) { - self = BigInt(value, radix: 10)! - } -} - -extension BigUInt: CustomStringConvertible { - /// Return the decimal representation of this integer. - public var description: String { - return String(self, radix: 10) - } -} - -extension BigInt: CustomStringConvertible { - /// Return the decimal representation of this integer. - public var description: String { - return String(self, radix: 10) - } -} - -extension BigUInt: CustomPlaygroundDisplayConvertible { - - /// Return the playground quick look representation of this integer. - public var playgroundDescription: Any { - let text = String(self) - return text + " (\(self.bitWidth) bits)" - } -} - -extension BigInt: CustomPlaygroundDisplayConvertible { - - /// Return the playground quick look representation of this integer. - public var playgroundDescription: Any { - let text = String(self) - return text + " (\(self.magnitude.bitWidth) bits)" - } -} diff --git a/Carthage/Checkouts/BigInt/Sources/Subtraction.swift b/Carthage/Checkouts/BigInt/Sources/Subtraction.swift deleted file mode 100644 index 5ac872e65..000000000 --- a/Carthage/Checkouts/BigInt/Sources/Subtraction.swift +++ /dev/null @@ -1,169 +0,0 @@ -// -// Subtraction.swift -// BigInt -// -// Created by Károly Lőrentey on 2016-01-03. -// Copyright © 2016-2017 Károly Lőrentey. -// - -extension BigUInt { - //MARK: Subtraction - - /// Subtract `word` from this integer in place, returning a flag indicating if the operation - /// caused an arithmetic overflow. `word` is shifted `shift` words to the left before being subtracted. - /// - /// - Note: If the result indicates an overflow, then `self` becomes the two's complement of the absolute difference. - /// - Complexity: O(count) - internal mutating func subtractWordReportingOverflow(_ word: Word, shiftedBy shift: Int = 0) -> Bool { - precondition(shift >= 0) - var carry: Word = word - var i = shift - let count = self.count - while carry > 0 && i < count { - let (d, c) = self[i].subtractingReportingOverflow(carry) - self[i] = d - carry = (c ? 1 : 0) - i += 1 - } - return carry > 0 - } - - /// Subtract `word` from this integer, returning the difference and a flag that is true if the operation - /// caused an arithmetic overflow. `word` is shifted `shift` words to the left before being subtracted. - /// - /// - Note: If `overflow` is true, then the returned value is the two's complement of the absolute difference. - /// - Complexity: O(count) - internal func subtractingWordReportingOverflow(_ word: Word, shiftedBy shift: Int = 0) -> (partialValue: BigUInt, overflow: Bool) { - var result = self - let overflow = result.subtractWordReportingOverflow(word, shiftedBy: shift) - return (result, overflow) - } - - /// Subtract a digit `d` from this integer in place. - /// `d` is shifted `shift` digits to the left before being subtracted. - /// - /// - Requires: self >= d * 2^shift - /// - Complexity: O(count) - internal mutating func subtractWord(_ word: Word, shiftedBy shift: Int = 0) { - let overflow = subtractWordReportingOverflow(word, shiftedBy: shift) - precondition(!overflow) - } - - /// Subtract a digit `d` from this integer and return the result. - /// `d` is shifted `shift` digits to the left before being subtracted. - /// - /// - Requires: self >= d * 2^shift - /// - Complexity: O(count) - internal func subtractingWord(_ word: Word, shiftedBy shift: Int = 0) -> BigUInt { - var result = self - result.subtractWord(word, shiftedBy: shift) - return result - } - - /// Subtract `other` from this integer in place, and return a flag indicating if the operation caused an - /// arithmetic overflow. `other` is shifted `shift` digits to the left before being subtracted. - /// - /// - Note: If the result indicates an overflow, then `self` becomes the twos' complement of the absolute difference. - /// - Complexity: O(count) - public mutating func subtractReportingOverflow(_ b: BigUInt, shiftedBy shift: Int = 0) -> Bool { - precondition(shift >= 0) - var carry = false - var bi = 0 - let bc = b.count - let count = self.count - while bi < bc || (shift + bi < count && carry) { - let ai = shift + bi - let (d, c) = self[ai].subtractingReportingOverflow(b[bi]) - if carry { - let (d2, c2) = d.subtractingReportingOverflow(1) - self[ai] = d2 - carry = c || c2 - } - else { - self[ai] = d - carry = c - } - bi += 1 - } - return carry - } - - /// Subtract `other` from this integer, returning the difference and a flag indicating arithmetic overflow. - /// `other` is shifted `shift` digits to the left before being subtracted. - /// - /// - Note: If `overflow` is true, then the result value is the twos' complement of the absolute value of the difference. - /// - Complexity: O(count) - public func subtractingReportingOverflow(_ other: BigUInt, shiftedBy shift: Int) -> (partialValue: BigUInt, overflow: Bool) { - var result = self - let overflow = result.subtractReportingOverflow(other, shiftedBy: shift) - return (result, overflow) - } - - /// Subtracts `other` from `self`, returning the result and a flag indicating arithmetic overflow. - /// - /// - Note: When the operation overflows, then `partialValue` is the twos' complement of the absolute value of the difference. - /// - Complexity: O(count) - public func subtractingReportingOverflow(_ other: BigUInt) -> (partialValue: BigUInt, overflow: Bool) { - return self.subtractingReportingOverflow(other, shiftedBy: 0) - } - - /// Subtract `other` from this integer in place. - /// `other` is shifted `shift` digits to the left before being subtracted. - /// - /// - Requires: self >= other * 2^shift - /// - Complexity: O(count) - public mutating func subtract(_ other: BigUInt, shiftedBy shift: Int = 0) { - let overflow = subtractReportingOverflow(other, shiftedBy: shift) - precondition(!overflow) - } - - /// Subtract `b` from this integer, and return the difference. - /// `b` is shifted `shift` digits to the left before being subtracted. - /// - /// - Requires: self >= b * 2^shift - /// - Complexity: O(count) - public func subtracting(_ other: BigUInt, shiftedBy shift: Int = 0) -> BigUInt { - var result = self - result.subtract(other, shiftedBy: shift) - return result - } - - /// Decrement this integer by one. - /// - /// - Requires: !isZero - /// - Complexity: O(count) - public mutating func decrement(shiftedBy shift: Int = 0) { - self.subtract(1, shiftedBy: shift) - } - - /// Subtract `b` from `a` and return the result. - /// - /// - Requires: a >= b - /// - Complexity: O(a.count) - public static func -(a: BigUInt, b: BigUInt) -> BigUInt { - return a.subtracting(b) - } - - /// Subtract `b` from `a` and store the result in `a`. - /// - /// - Requires: a >= b - /// - Complexity: O(a.count) - public static func -=(a: inout BigUInt, b: BigUInt) { - a.subtract(b) - } -} - -extension BigInt { - public mutating func negate() { - guard !magnitude.isZero else { return } - self.sign = self.sign == .plus ? .minus : .plus - } - - /// Subtract `b` from `a` and return the result. - public static func -(a: BigInt, b: BigInt) -> BigInt { - return a + -b - } - - /// Subtract `b` from `a` in place. - public static func -=(a: inout BigInt, b: BigInt) { a = a - b } -} diff --git a/Carthage/Checkouts/BigInt/Sources/Words and Bits.swift b/Carthage/Checkouts/BigInt/Sources/Words and Bits.swift deleted file mode 100644 index 4543c1bc8..000000000 --- a/Carthage/Checkouts/BigInt/Sources/Words and Bits.swift +++ /dev/null @@ -1,202 +0,0 @@ -// -// Words and Bits.swift -// BigInt -// -// Created by Károly Lőrentey on 2017-08-11. -// Copyright © 2016-2017 Károly Lőrentey. -// - -extension Array where Element == UInt { - mutating func twosComplement() { - var increment = true - for i in 0 ..< self.count { - if increment { - (self[i], increment) = (~self[i]).addingReportingOverflow(1) - } - else { - self[i] = ~self[i] - } - } - } -} - -extension BigUInt { - public subscript(bitAt index: Int) -> Bool { - get { - precondition(index >= 0) - let (i, j) = index.quotientAndRemainder(dividingBy: Word.bitWidth) - return self[i] & (1 << j) != 0 - } - set { - precondition(index >= 0) - let (i, j) = index.quotientAndRemainder(dividingBy: Word.bitWidth) - if newValue { - self[i] |= 1 << j - } - else { - self[i] &= ~(1 << j) - } - } - } -} - -extension BigUInt { - /// The minimum number of bits required to represent this integer in binary. - /// - /// - Returns: floor(log2(2 * self + 1)) - /// - Complexity: O(1) - public var bitWidth: Int { - guard count > 0 else { return 0 } - return count * Word.bitWidth - self[count - 1].leadingZeroBitCount - } - - /// The number of leading zero bits in the binary representation of this integer in base `2^(Word.bitWidth)`. - /// This is useful when you need to normalize a `BigUInt` such that the top bit of its most significant word is 1. - /// - /// - Note: 0 is considered to have zero leading zero bits. - /// - Returns: A value in `0...(Word.bitWidth - 1)`. - /// - SeeAlso: width - /// - Complexity: O(1) - public var leadingZeroBitCount: Int { - guard count > 0 else { return 0 } - return self[count - 1].leadingZeroBitCount - } - - /// The number of trailing zero bits in the binary representation of this integer. - /// - /// - Note: 0 is considered to have zero trailing zero bits. - /// - Returns: A value in `0...width`. - /// - Complexity: O(count) - public var trailingZeroBitCount: Int { - guard count > 0 else { return 0 } - let i = self.words.firstIndex { $0 != 0 }! - return i * Word.bitWidth + self[i].trailingZeroBitCount - } -} - -extension BigInt { - public var bitWidth: Int { - guard !magnitude.isZero else { return 0 } - return magnitude.bitWidth + 1 - } - - public var trailingZeroBitCount: Int { - // Amazingly, this works fine for negative numbers - return magnitude.trailingZeroBitCount - } -} - -extension BigUInt { - public struct Words: RandomAccessCollection { - private let value: BigUInt - - fileprivate init(_ value: BigUInt) { self.value = value } - - public var startIndex: Int { return 0 } - public var endIndex: Int { return value.count } - - public subscript(_ index: Int) -> Word { - return value[index] - } - } - - public var words: Words { return Words(self) } - - public init(words: Words) where Words.Element == Word { - let uc = words.underestimatedCount - if uc > 2 { - self.init(words: Array(words)) - } - else { - var it = words.makeIterator() - guard let w0 = it.next() else { - self.init() - return - } - guard let w1 = it.next() else { - self.init(word: w0) - return - } - if let w2 = it.next() { - var words: [UInt] = [] - words.reserveCapacity(Swift.max(3, uc)) - words.append(w0) - words.append(w1) - words.append(w2) - while let word = it.next() { - words.append(word) - } - self.init(words: words) - } - else { - self.init(low: w0, high: w1) - } - } - } -} - -extension BigInt { - public struct Words: RandomAccessCollection { - public typealias Indices = CountableRange - - private let value: BigInt - private let decrementLimit: Int - - fileprivate init(_ value: BigInt) { - self.value = value - switch value.sign { - case .plus: - self.decrementLimit = 0 - case .minus: - assert(!value.magnitude.isZero) - self.decrementLimit = value.magnitude.words.firstIndex(where: { $0 != 0 })! - } - } - - public var count: Int { - switch value.sign { - case .plus: - if let high = value.magnitude.words.last, high >> (Word.bitWidth - 1) != 0 { - return value.magnitude.count + 1 - } - return value.magnitude.count - case .minus: - let high = value.magnitude.words.last! - if high >> (Word.bitWidth - 1) != 0 { - return value.magnitude.count + 1 - } - return value.magnitude.count - } - } - - public var indices: Indices { return 0 ..< count } - public var startIndex: Int { return 0 } - public var endIndex: Int { return count } - - public subscript(_ index: Int) -> UInt { - // Note that indices above `endIndex` are accepted. - if value.sign == .plus { - return value.magnitude[index] - } - if index <= decrementLimit { - return ~(value.magnitude[index] &- 1) - } - return ~value.magnitude[index] - } - } - - public var words: Words { - return Words(self) - } - - public init(words: S) where S.Element == Word { - var words = Array(words) - if (words.last ?? 0) >> (Word.bitWidth - 1) == 0 { - self.init(sign: .plus, magnitude: BigUInt(words: words)) - } - else { - words.twosComplement() - self.init(sign: .minus, magnitude: BigUInt(words: words)) - } - } -} diff --git a/Carthage/Checkouts/BigInt/Tests/BigIntTests/BigIntTests.swift b/Carthage/Checkouts/BigInt/Tests/BigIntTests/BigIntTests.swift deleted file mode 100644 index 651ce8f75..000000000 --- a/Carthage/Checkouts/BigInt/Tests/BigIntTests/BigIntTests.swift +++ /dev/null @@ -1,683 +0,0 @@ -// -// BigIntTests.swift -// BigIntTests -// -// Created by Károly Lőrentey on 2015-12-26. -// Copyright © 2016-2017 Károly Lőrentey. -// - -import XCTest -@testable import BigInt - -class BigIntTests: XCTestCase { - typealias Word = BigInt.Word - - func testSigns() { - XCTAssertTrue(BigInt.isSigned) - - XCTAssertEqual(BigInt().signum(), 0) - XCTAssertEqual(BigInt(-2).signum(), -1) - XCTAssertEqual(BigInt(-1).signum(), -1) - XCTAssertEqual(BigInt(0).signum(), 0) - XCTAssertEqual(BigInt(1).signum(), 1) - XCTAssertEqual(BigInt(2).signum(), 1) - - XCTAssertEqual(BigInt(words: [0, Word.max]).signum(), -1) - XCTAssertEqual(BigInt(words: [0, 1]).signum(), 1) - } - - func testInit() { - XCTAssertEqual(BigInt().sign, .plus) - XCTAssertEqual(BigInt().magnitude, 0) - - XCTAssertEqual(BigInt(Int64.min).sign, .minus) - XCTAssertEqual(BigInt(Int64.min).magnitude - 1, BigInt(Int64.max).magnitude) - - let zero = BigInt(0) - XCTAssertTrue(zero.magnitude.isZero) - XCTAssertEqual(zero.sign, .plus) - - let minusOne = BigInt(-1) - XCTAssertEqual(minusOne.magnitude, 1) - XCTAssertEqual(minusOne.sign, .minus) - - let b: BigInt = 42 - XCTAssertEqual(b.magnitude, 42) - XCTAssertEqual(b.sign, .plus) - - XCTAssertEqual(BigInt(UInt64.max).magnitude, BigUInt(UInt64.max)) - - let b2: BigInt = "+300" - XCTAssertEqual(b2.magnitude, 300) - XCTAssertEqual(b2.sign, .plus) - - let b3: BigInt = "-300" - XCTAssertEqual(b3.magnitude, 300) - XCTAssertEqual(b3.sign, .minus) - - // We have to call BigInt.init here because we don't want Literal initialization via coercion (SE-0213) - XCTAssertNil(BigInt.init("Not a number")) - XCTAssertEqual(BigInt(unicodeScalarLiteral: UnicodeScalar(52)), BigInt(4)) - XCTAssertEqual(BigInt(extendedGraphemeClusterLiteral: "4"), BigInt(4)) - - XCTAssertEqual(BigInt(words: []), 0) - XCTAssertEqual(BigInt(words: [1, 1]), BigInt(1) << Word.bitWidth + 1) - XCTAssertEqual(BigInt(words: [1, 2]), BigInt(2) << Word.bitWidth + 1) - XCTAssertEqual(BigInt(words: [0, Word.max]), -(BigInt(1) << Word.bitWidth)) - XCTAssertEqual(BigInt(words: [1, Word.max]), -BigInt(Word.max)) - XCTAssertEqual(BigInt(words: [1, Word.max, Word.max]), -BigInt(Word.max)) - - XCTAssertEqual(BigInt(exactly: 1), BigInt(1)) - XCTAssertEqual(BigInt(exactly: -1), BigInt(-1)) - } - - func testInit_FloatingPoint() { - XCTAssertEqual(BigInt(42.0), 42) - XCTAssertEqual(BigInt(-42.0), -42) - XCTAssertEqual(BigInt(42.5), 42) - XCTAssertEqual(BigInt(-42.5), -42) - XCTAssertEqual(BigInt(exactly: 42.0), 42) - XCTAssertEqual(BigInt(exactly: -42.0), -42) - XCTAssertNil(BigInt(exactly: 42.5)) - XCTAssertNil(BigInt(exactly: -42.5)) - XCTAssertNil(BigInt(exactly: Double.leastNormalMagnitude)) - XCTAssertNil(BigInt(exactly: Double.leastNonzeroMagnitude)) - XCTAssertNil(BigInt(exactly: Double.infinity)) - XCTAssertNil(BigInt(exactly: Double.nan)) - XCTAssertNil(BigInt(exactly: Double.signalingNaN)) - XCTAssertEqual(BigInt(clamping: -42), -42) - XCTAssertEqual(BigInt(clamping: 42), 42) - XCTAssertEqual(BigInt(truncatingIfNeeded: -42), -42) - XCTAssertEqual(BigInt(truncatingIfNeeded: 42), 42) - } - - func testInit_Buffer() { - func test(_ b: BigInt, _ d: Array, file: StaticString = #file, line: UInt = #line) { - d.withUnsafeBytes { buffer in - let initialized = BigInt(buffer) - XCTAssertEqual(initialized, b, file: file, line: line) - } - } - - // Positive integers - test(BigInt(), []) - test(BigInt(1), [0x00, 0x01]) - test(BigInt(2), [0x00, 0x02]) - test(BigInt(0x0102030405060708), [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08]) - test(BigInt(0x01) << 64 + BigInt(0x0203040506070809), [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09]) - - // Negative integers - test(BigInt(), []) - test(BigInt(-1), [0x01, 0x01]) - test(BigInt(-2), [0x01, 0x02]) - test(BigInt(0x0102030405060708) * BigInt(-1), [0x01, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08]) - test((BigInt(0x01) << 64 + BigInt(0x0203040506070809)) * BigInt(-1), [0x01, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09]) - } - - func testConversionToFloatingPoint() { - func test(_ a: BigInt, _ b: F, file: StaticString = #file, line: UInt = #line) - where F.RawExponent: FixedWidthInteger, F.RawSignificand: FixedWidthInteger { - let f = F(a) - XCTAssertEqual(f, b, file: file, line: line) - } - - for i in -100 ..< 100 { - test(BigInt(i), Double(i)) - } - test(BigInt(0x5A5A5A), 0x5A5A5A as Double) - test(BigInt(1) << 64, 0x1p64 as Double) - test(BigInt(0x5A5A5A) << 64, 0x5A5A5Ap64 as Double) - test(BigInt(1) << 1023, 0x1p1023 as Double) - test(BigInt(10) << 1020, 0xAp1020 as Double) - test(BigInt(1) << 1024, Double.infinity) - test(BigInt(words: convertWords([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFFFFFFFFFFFFF800, 0])), - Double.greatestFiniteMagnitude) - - for i in -100 ..< 100 { - test(BigInt(i), Float(i)) - } - test(BigInt(0x5A5A5A), 0x5A5A5A as Float) - test(BigInt(1) << 64, 0x1p64 as Float) - test(BigInt(0x5A5A5A) << 64, 0x5A5A5Ap64 as Float) - test(BigInt(1) << 1023, 0x1p1023 as Float) - test(BigInt(10) << 1020, 0xAp1020 as Float) - test(BigInt(1) << 1024, Float.infinity) - test(BigInt(words: convertWords([0, 0xFFFFFF0000000000, 0])), - Float.greatestFiniteMagnitude) - } - - func testTwosComplement() { - func check(_ a: [Word], _ b: [Word], file: StaticString = #file, line: UInt = #line) { - var a2 = a - a2.twosComplement() - XCTAssertEqual(a2, b, file: file, line: line) - var b2 = b - b2.twosComplement() - XCTAssertEqual(b2, a, file: file, line: line) - } - check([1], [Word.max]) - check([Word.max], [1]) - check([1, 1], [Word.max, Word.max - 1]) - check([(1 as Word) << (Word.bitWidth - 1)], [(1 as Word) << (Word.bitWidth - 1)]) - check([0], [0]) - check([0, 0, 1], [0, 0, Word.max]) - check([0, 0, 1, 0, 1], [0, 0, Word.max, Word.max, Word.max - 1]) - check([0, 0, 1, 1], [0, 0, Word.max, Word.max - 1]) - check([0, 0, 1, 0, 0, 0], [0, 0, Word.max, Word.max, Word.max, Word.max]) - } - - func testSign() { - XCTAssertEqual(BigInt(-1).sign, .minus) - XCTAssertEqual(BigInt(0).sign, .plus) - XCTAssertEqual(BigInt(1).sign, .plus) - } - - func testBitWidth() { - XCTAssertEqual(BigInt(0).bitWidth, 0) - XCTAssertEqual(BigInt(1).bitWidth, 2) - XCTAssertEqual(BigInt(-1).bitWidth, 2) - XCTAssertEqual((BigInt(1) << 64).bitWidth, Word.bitWidth + 2) - XCTAssertEqual(BigInt(Word.max).bitWidth, Word.bitWidth + 1) - XCTAssertEqual(BigInt(Word.max >> 1).bitWidth, Word.bitWidth) - } - - func testTrailingZeroBitCount() { - XCTAssertEqual(BigInt(0).trailingZeroBitCount, 0) - XCTAssertEqual(BigInt(1).trailingZeroBitCount, 0) - XCTAssertEqual(BigInt(-1).trailingZeroBitCount, 0) - XCTAssertEqual(BigInt(2).trailingZeroBitCount, 1) - XCTAssertEqual(BigInt(Word.max).trailingZeroBitCount, 0) - XCTAssertEqual(BigInt(-2).trailingZeroBitCount, 1) - XCTAssertEqual(-BigInt(Word.max).trailingZeroBitCount, 0) - XCTAssertEqual((BigInt(1) << 100).trailingZeroBitCount, 100) - XCTAssertEqual(((-BigInt(1)) << 100).trailingZeroBitCount, 100) - } - - func testWords() { - XCTAssertEqual(Array(BigInt(0).words), []) - XCTAssertEqual(Array(BigInt(1).words), [1]) - XCTAssertEqual(Array(BigInt(-1).words), [Word.max]) - - let highBit = (1 as Word) << (Word.bitWidth - 1) - XCTAssertEqual(Array(BigInt(highBit).words), [highBit, 0]) - XCTAssertEqual(Array((-BigInt(highBit)).words), [highBit, Word.max]) - - XCTAssertEqual(Array(BigInt(sign: .plus, magnitude: BigUInt(words: [Word.max])).words), [Word.max, 0]) - XCTAssertEqual(Array(BigInt(sign: .minus, magnitude: BigUInt(words: [Word.max])).words), [1, Word.max]) - - XCTAssertEqual(Array((BigInt(1) << Word.bitWidth).words), [0, 1]) - XCTAssertEqual(Array((-(BigInt(1) << Word.bitWidth)).words), [0, Word.max]) - - XCTAssertEqual(Array((BigInt(42) << Word.bitWidth).words), [0, 42]) - XCTAssertEqual(Array((-(BigInt(42) << Word.bitWidth)).words), [0, Word.max - 41]) - - let huge = BigUInt(words: [0, 1, 2, 3, 4]) - XCTAssertEqual(Array(BigInt(sign: .plus, magnitude: huge).words), [0, 1, 2, 3, 4]) - XCTAssertEqual(Array(BigInt(sign: .minus, magnitude: huge).words), - [0, Word.max, ~2, ~3, ~4] as [Word]) - - - XCTAssertEqual(BigInt(1).words[100], 0) - XCTAssertEqual(BigInt(-1).words[100], Word.max) - - XCTAssertEqual(BigInt(words: [0, 1, 2, 3, 4]).words.indices, 0 ..< 5) - } - - func testComplement() { - XCTAssertEqual(~BigInt(-3), BigInt(2)) - XCTAssertEqual(~BigInt(-2), BigInt(1)) - XCTAssertEqual(~BigInt(-1), BigInt(0)) - XCTAssertEqual(~BigInt(0), BigInt(-1)) - XCTAssertEqual(~BigInt(1), BigInt(-2)) - XCTAssertEqual(~BigInt(2), BigInt(-3)) - - XCTAssertEqual(~BigInt(words: [1, 2, 3, 4]), - BigInt(words: [Word.max - 1, Word.max - 2, Word.max - 3, Word.max - 4])) - XCTAssertEqual(~BigInt(words: [Word.max - 1, Word.max - 2, Word.max - 3, Word.max - 4]), - BigInt(words: [1, 2, 3, 4])) - } - - func testBinaryAnd() { - XCTAssertEqual(BigInt(1) & BigInt(2), 0) - XCTAssertEqual(BigInt(-1) & BigInt(2), 2) - XCTAssertEqual(BigInt(-1) & BigInt(words: [1, 2, 3, 4]), BigInt(words: [1, 2, 3, 4])) - XCTAssertEqual(BigInt(-1) & -BigInt(words: [1, 2, 3, 4]), -BigInt(words: [1, 2, 3, 4])) - XCTAssertEqual(BigInt(Word.max) & BigInt(words: [1, 2, 3, 4]), BigInt(1)) - XCTAssertEqual(BigInt(Word.max) & BigInt(words: [Word.max, 1, 2]), BigInt(Word.max)) - XCTAssertEqual(BigInt(Word.max) & BigInt(words: [Word.max, Word.max - 1]), BigInt(Word.max)) - } - - func testBinaryOr() { - XCTAssertEqual(BigInt(1) | BigInt(2), 3) - XCTAssertEqual(BigInt(-1) | BigInt(2), -1) - XCTAssertEqual(BigInt(-1) | BigInt(words: [1, 2, 3, 4]), -1) - XCTAssertEqual(BigInt(-1) | -BigInt(words: [1, 2, 3, 4]), -1) - XCTAssertEqual(BigInt(Word.max) | BigInt(words: [1, 2, 3, 4]), - BigInt(words: [Word.max, 2, 3, 4])) - XCTAssertEqual(BigInt(Word.max) | BigInt(words: [1, 2, 3, Word.max]), - BigInt(words: [Word.max, 2, 3, Word.max])) - XCTAssertEqual(BigInt(Word.max) | BigInt(words: [Word.max - 1, Word.max - 1]), - BigInt(words: [Word.max, Word.max - 1])) - } - - func testBinaryXor() { - XCTAssertEqual(BigInt(1) ^ BigInt(2), 3) - XCTAssertEqual(BigInt(-1) ^ BigInt(2), -3) - XCTAssertEqual(BigInt(1) ^ BigInt(-2), -1) - XCTAssertEqual(BigInt(-1) ^ BigInt(-2), 1) - XCTAssertEqual(BigInt(-1) ^ BigInt(words: [1, 2, 3, 4]), - BigInt(words: [~1, ~2, ~3, ~4] as [Word])) - XCTAssertEqual(BigInt(-1) ^ -BigInt(words: [1, 2, 3, 4]), - BigInt(words: [0, 2, 3, 4])) - XCTAssertEqual(BigInt(Word.max) ^ BigInt(words: [1, 2, 3, 4]), - BigInt(words: [~1, 2, 3, 4] as [Word])) - XCTAssertEqual(BigInt(Word.max) ^ BigInt(words: [1, 2, 3, Word.max]), - BigInt(words: [~1, 2, 3, Word.max] as [Word])) - XCTAssertEqual(BigInt(Word.max) ^ BigInt(words: [Word.max - 1, Word.max - 1]), - BigInt(words: [1, Word.max - 1])) - } - - func testConversionToString() { - let b = BigInt(-256) - XCTAssertEqual(b.description, "-256") - XCTAssertEqual(String(b, radix: 16, uppercase: true), "-100") - let pql = b.playgroundDescription as? String - if pql == "-256 (9 bits)" {} - else { - XCTFail("Unexpected Playground Quick Look: \(pql ?? "nil")") - } - } - - func testComparable() { - XCTAssertTrue(BigInt(1) == BigInt(1)) - XCTAssertFalse(BigInt(1) == BigInt(-1)) - - XCTAssertTrue(BigInt(1) < BigInt(42)) - XCTAssertFalse(BigInt(1) < -BigInt(42)) - XCTAssertTrue(BigInt(-1) < BigInt(42)) - XCTAssertTrue(BigInt(-42) < BigInt(-1)) - } - - func testHashable() { - XCTAssertEqual(BigInt(1).hashValue, BigInt(1).hashValue) - XCTAssertNotEqual(BigInt(1).hashValue, BigInt(2).hashValue) - XCTAssertNotEqual(BigInt(42).hashValue, BigInt(-42).hashValue) - XCTAssertNotEqual(BigInt(1).hashValue, BigInt(-1).hashValue) - } - - func testStrideable() { - XCTAssertEqual(BigInt(1).advanced(by: 100), 101) - XCTAssertEqual(BigInt(Word.max).advanced(by: 1 as BigInt.Stride), BigInt(1) << Word.bitWidth) - - XCTAssertEqual(BigInt(Word.max).distance(to: BigInt(words: [0, 1])), BigInt(1)) - XCTAssertEqual(BigInt(words: [0, 1]).distance(to: BigInt(Word.max)), BigInt(-1)) - XCTAssertEqual(BigInt(0).distance(to: BigInt(words: [0, 1])), BigInt(words: [0, 1])) - } - - func compare(_ a: Int, _ b: Int, r: Int, file: StaticString = #file, line: UInt = #line, op: (BigInt, BigInt) -> BigInt) { - XCTAssertEqual(op(BigInt(a), BigInt(b)), BigInt(r), file: file, line: line) - } - - func testAddition() { - compare(0, 0, r: 0, op: +) - compare(1, 2, r: 3, op: +) - compare(1, -2, r: -1, op: +) - compare(-1, 2, r: 1, op: +) - compare(-1, -2, r: -3, op: +) - compare(2, -1, r: 1, op: +) - } - - func testNegation() { - XCTAssertEqual(-BigInt(0), BigInt(0)) - XCTAssertEqual(-BigInt(1), BigInt(-1)) - XCTAssertEqual(-BigInt(-1), BigInt(1)) - } - - func testSubtraction() { - compare(0, 0, r: 0, op: -) - compare(2, 1, r: 1, op: -) - compare(2, -1, r: 3, op: -) - compare(-2, 1, r: -3, op: -) - compare(-2, -1, r: -1, op: -) - } - - func testMultiplication() { - compare(0, 0, r: 0, op: *) - compare(0, 1, r: 0, op: *) - compare(1, 0, r: 0, op: *) - compare(0, -1, r: 0, op: *) - compare(-1, 0, r: 0, op: *) - compare(2, 3, r: 6, op: *) - compare(2, -3, r: -6, op: *) - compare(-2, 3, r: -6, op: *) - compare(-2, -3, r: 6, op: *) - } - - func testQuotientAndRemainder() { - func compare(_ a: BigInt, _ b: BigInt, r: (BigInt, BigInt), file: StaticString = #file, line: UInt = #line) { - let actual = a.quotientAndRemainder(dividingBy: b) - XCTAssertEqual(actual.quotient, r.0, "quotient", file: file, line: line) - XCTAssertEqual(actual.remainder, r.1, "remainder", file: file, line: line) - } - - compare(0, 1, r: (0, 0)) - compare(0, -1, r: (0, 0)) - compare(7, 4, r: (1, 3)) - compare(7, -4, r: (-1, 3)) - compare(-7, 4, r: (-1, -3)) - compare(-7, -4, r: (1, -3)) - } - - func testDivision() { - compare(0, 1, r: 0, op: /) - compare(0, -1, r: 0, op: /) - compare(7, 4, r: 1, op: /) - compare(7, -4, r: -1, op: /) - compare(-7, 4, r: -1, op: /) - compare(-7, -4, r: 1, op: /) - } - - func testRemainder() { - compare(0, 1, r: 0, op: %) - compare(0, -1, r: 0, op: %) - compare(7, 4, r: 3, op: %) - compare(7, -4, r: 3, op: %) - compare(-7, 4, r: -3, op: %) - compare(-7, -4, r:-3, op: %) - } - - func testModulo() { - XCTAssertEqual(BigInt(22).modulus(5), 2) - XCTAssertEqual(BigInt(-22).modulus(5), 3) - XCTAssertEqual(BigInt(22).modulus(-5), 2) - XCTAssertEqual(BigInt(-22).modulus(-5), 3) - } - - func testStrideableRequirements() { - XCTAssertEqual(5, BigInt(3).advanced(by: 2)) - XCTAssertEqual(2, BigInt(3).distance(to: 5)) - } - - func testAbsoluteValuableRequirements() { - XCTAssertEqual(BigInt(5), abs(5 as BigInt)) - XCTAssertEqual(BigInt(0), abs(0 as BigInt)) - XCTAssertEqual(BigInt(5), abs(-5 as BigInt)) - } - - func testIntegerArithmeticRequirements() { - XCTAssertEqual(3 as Int64, Int64(3 as BigInt)) - XCTAssertEqual(-3 as Int64, Int64(-3 as BigInt)) - } - - func testAssignmentOperators() { - var a = BigInt(1) - a += 13 - XCTAssertEqual(a, 14) - - a -= 7 - XCTAssertEqual(a, 7) - - a *= 3 - XCTAssertEqual(a, 21) - - a /= 2 - XCTAssertEqual(a, 10) - - a %= 7 - XCTAssertEqual(a, 3) - } - - func testExponentiation() { - XCTAssertEqual(BigInt(0).power(0), 1) - XCTAssertEqual(BigInt(0).power(1), 0) - XCTAssertEqual(BigInt(0).power(2), 0) - - XCTAssertEqual(BigInt(1).power(-2), 1) - XCTAssertEqual(BigInt(1).power(-1), 1) - XCTAssertEqual(BigInt(1).power(0), 1) - XCTAssertEqual(BigInt(1).power(1), 1) - XCTAssertEqual(BigInt(1).power(2), 1) - - XCTAssertEqual(BigInt(2).power(-4), 0) - XCTAssertEqual(BigInt(2).power(-3), 0) - XCTAssertEqual(BigInt(2).power(-2), 0) - XCTAssertEqual(BigInt(2).power(-1), 0) - XCTAssertEqual(BigInt(2).power(0), 1) - XCTAssertEqual(BigInt(2).power(1), 2) - XCTAssertEqual(BigInt(2).power(2), 4) - XCTAssertEqual(BigInt(2).power(3), 8) - XCTAssertEqual(BigInt(2).power(4), 16) - - XCTAssertEqual(BigInt(-1).power(-4), 1) - XCTAssertEqual(BigInt(-1).power(-3), -1) - XCTAssertEqual(BigInt(-1).power(-2), 1) - XCTAssertEqual(BigInt(-1).power(-1), -1) - XCTAssertEqual(BigInt(-1).power(0), 1) - XCTAssertEqual(BigInt(-1).power(1), -1) - XCTAssertEqual(BigInt(-1).power(2), 1) - XCTAssertEqual(BigInt(-1).power(3), -1) - XCTAssertEqual(BigInt(-1).power(4), 1) - - XCTAssertEqual(BigInt(-2).power(-4), 0) - XCTAssertEqual(BigInt(-2).power(-3), 0) - XCTAssertEqual(BigInt(-2).power(-2), 0) - XCTAssertEqual(BigInt(-2).power(-1), 0) - XCTAssertEqual(BigInt(-2).power(0), 1) - XCTAssertEqual(BigInt(-2).power(1), -2) - XCTAssertEqual(BigInt(-2).power(2), 4) - XCTAssertEqual(BigInt(-2).power(3), -8) - XCTAssertEqual(BigInt(-2).power(4), 16) - } - - func testModularExponentiation() { - for i in -5 ... 5 { - for j in -5 ... 5 { - for m in [-7, -5, -3, -2, -1, 1, 2, 3, 5, 7] { - guard i != 0 || j >= 0 else { continue } - XCTAssertEqual(BigInt(i).power(BigInt(j), modulus: BigInt(m)), - BigInt(i).power(j).modulus(BigInt(m)), - "\(i), \(j), \(m)") - } - } - } - } - - func testSquareRoot() { - XCTAssertEqual(BigInt(0).squareRoot(), 0) - XCTAssertEqual(BigInt(1).squareRoot(), 1) - XCTAssertEqual(BigInt(2).squareRoot(), 1) - XCTAssertEqual(BigInt(3).squareRoot(), 1) - XCTAssertEqual(BigInt(4).squareRoot(), 2) - XCTAssertEqual(BigInt(5).squareRoot(), 2) - XCTAssertEqual(BigInt(9).squareRoot(), 3) - } - - func testGCD() { - XCTAssertEqual(BigInt(12).greatestCommonDivisor(with: 15), 3) - XCTAssertEqual(BigInt(-12).greatestCommonDivisor(with: 15), 3) - XCTAssertEqual(BigInt(12).greatestCommonDivisor(with: -15), 3) - XCTAssertEqual(BigInt(-12).greatestCommonDivisor(with: -15), 3) - } - - func testInverse() { - for base in -100 ... 100 { - for modulus in [2, 3, 4, 5] { - let base = BigInt(base) - let modulus = BigInt(modulus) - if let inverse = base.inverse(modulus) { - XCTAssertEqual((base * inverse).modulus(modulus), 1, "\(base), \(modulus), \(inverse)") - } - else { - XCTAssertGreaterThan(BigInt(base).greatestCommonDivisor(with: modulus), 1, "\(base), \(modulus)") - } - } - } - } - - func testPrimes() { - XCTAssertFalse(BigInt(-7).isPrime()) - XCTAssertTrue(BigInt(103).isPrime()) - - XCTAssertFalse(BigInt(-3_215_031_751).isStrongProbablePrime(7)) - XCTAssertTrue(BigInt(3_215_031_751).isStrongProbablePrime(7)) - XCTAssertFalse(BigInt(3_215_031_751).isPrime()) - } - - func testShifts() { - XCTAssertEqual(BigInt(1) << Word.bitWidth, BigInt(words: [0, 1])) - XCTAssertEqual(BigInt(-1) << Word.bitWidth, BigInt(words: [0, Word.max])) - XCTAssertEqual(BigInt(words: [0, 1]) << -Word.bitWidth, BigInt(1)) - - XCTAssertEqual(BigInt(words: [0, 1]) >> Word.bitWidth, BigInt(1)) - XCTAssertEqual(BigInt(-1) >> Word.bitWidth, BigInt(-1)) - XCTAssertEqual(BigInt(1) >> Word.bitWidth, BigInt(0)) - XCTAssertEqual(BigInt(words: [0, Word.max]) >> Word.bitWidth, BigInt(-1)) - XCTAssertEqual(BigInt(1) >> -Word.bitWidth, BigInt(words: [0, 1])) - - XCTAssertEqual(BigInt(1) &<< BigInt(Word.bitWidth), BigInt(words: [0, 1])) - XCTAssertEqual(BigInt(words: [0, 1]) &>> BigInt(Word.bitWidth), BigInt(1)) - } - - func testShiftAssignments() { - - var a: BigInt = 1 - a <<= Word.bitWidth - XCTAssertEqual(a, BigInt(words: [0, 1])) - - a = -1 - a <<= Word.bitWidth - XCTAssertEqual(a, BigInt(words: [0, Word.max])) - - a = BigInt(words: [0, 1]) - a <<= -Word.bitWidth - XCTAssertEqual(a, 1) - - a = BigInt(words: [0, 1]) - a >>= Word.bitWidth - XCTAssertEqual(a, 1) - - a = -1 - a >>= Word.bitWidth - XCTAssertEqual(a, -1) - - a = 1 - a >>= Word.bitWidth - XCTAssertEqual(a, 0) - - a = BigInt(words: [0, Word.max]) - a >>= Word.bitWidth - XCTAssertEqual(a, BigInt(-1)) - - a = 1 - a >>= -Word.bitWidth - XCTAssertEqual(a, BigInt(words: [0, 1])) - - a = 1 - a &<<= BigInt(Word.bitWidth) - XCTAssertEqual(a, BigInt(words: [0, 1])) - - a = BigInt(words: [0, 1]) - a &>>= BigInt(Word.bitWidth) - XCTAssertEqual(a, BigInt(1)) - - } - - func testCodable() { - func test(_ a: BigInt, file: StaticString = #file, line: UInt = #line) { - do { - let json = try JSONEncoder().encode(a) - print(String(data: json, encoding: .utf8)!) - let b = try JSONDecoder().decode(BigInt.self, from: json) - XCTAssertEqual(a, b, file: file, line: line) - } - catch let error { - XCTFail("Error thrown: \(error.localizedDescription)", file: file, line: line) - } - } - test(0) - test(1) - test(-1) - test(0x0102030405060708) - test(-0x0102030405060708) - test(BigInt(1) << 64) - test(-BigInt(1) << 64) - test(BigInt(words: [1, 2, 3, 4, 5, 6, 7])) - test(-BigInt(words: [1, 2, 3, 4, 5, 6, 7])) - - XCTAssertThrowsError(try JSONDecoder().decode(BigUInt.self, from: "[\"*\", 1]".data(using: .utf8)!)) { error in - guard let error = error as? DecodingError else { XCTFail("Expected a decoding error"); return } - guard case .dataCorrupted(let context) = error else { XCTFail("Expected a dataCorrupted error"); return } - XCTAssertEqual(context.debugDescription, "Invalid big integer sign") - } - } - - func testConversionToData() { - func test(_ b: BigInt, _ d: Array, file: StaticString = #file, line: UInt = #line) { - let expected = Data(d) - let actual = b.serialize() - XCTAssertEqual(actual, expected, file: file, line: line) - XCTAssertEqual(BigInt(actual), b, file: file, line: line) - } - - // Positive integers - test(BigInt(), []) - test(BigInt(1), [0x00, 0x01]) - test(BigInt(2), [0x00, 0x02]) - test(BigInt(0x0102030405060708), [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08]) - test(BigInt(0x01) << 64 + BigInt(0x0203040506070809), [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 09]) - - // Negative integers - test(BigInt(), []) - test(BigInt(-1), [0x01, 0x01]) - test(BigInt(-2), [0x01, 0x02]) - test(BigInt(0x0102030405060708) * BigInt(-1), [0x01, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08]) - test((BigInt(0x01) << 64 + BigInt(0x0203040506070809)) * BigInt(-1), [0x01, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 09]) - - } - - // - // you have to manually register linux tests here :-( - // - static var allTests = [ - ("testSigns", testSigns), - ("testInit", testInit), - ("testInit_FloatingPoint", testInit_FloatingPoint), - ("testInit_Buffer", testInit_Buffer), - ("testConversionToFloatingPoint", testConversionToFloatingPoint), - ("testTwosComplement", testTwosComplement), - ("testSign", testSign), - ("testBitWidth", testBitWidth), - ("testTrailingZeroBitCount", testTrailingZeroBitCount), - ("testWords", testWords), - ("testComplement", testComplement), - ("testBinaryAnd", testBinaryAnd), - ("testBinaryOr", testBinaryOr), - ("testBinaryXor", testBinaryXor), - ("testConversionToString", testConversionToString), - ("testComparable", testComparable), - ("testHashable", testHashable), - ("testStrideable", testStrideable), - ("testAddition", testAddition), - ("testNegation", testNegation), - ("testSubtraction", testSubtraction), - ("testMultiplication", testMultiplication), - ("testQuotientAndRemainder", testQuotientAndRemainder), - ("testDivision", testDivision), - ("testRemainder", testRemainder), - ("testModulo", testModulo), - ("testStrideableRequirements", testStrideableRequirements), - ("testAbsoluteValuableRequirements", testAbsoluteValuableRequirements), - ("testIntegerArithmeticRequirements", testIntegerArithmeticRequirements), - ("testAssignmentOperators", testAssignmentOperators), - ("testExponentiation", testExponentiation), - ("testModularExponentiation", testModularExponentiation), - ("testSquareRoot", testSquareRoot), - ("testGCD", testGCD), - ("testInverse", testInverse), - ("testPrimes", testPrimes), - ("testShifts", testShifts), - ("testShiftAssignments", testShiftAssignments), - ("testCodable", testCodable), - ("testConversionToData", testConversionToData) - ] -} diff --git a/Carthage/Checkouts/BigInt/Tests/BigIntTests/BigUIntTests.swift b/Carthage/Checkouts/BigInt/Tests/BigIntTests/BigUIntTests.swift deleted file mode 100644 index 92c01813a..000000000 --- a/Carthage/Checkouts/BigInt/Tests/BigIntTests/BigUIntTests.swift +++ /dev/null @@ -1,1536 +0,0 @@ -// -// BigUIntTests.swift -// BigInt -// -// Created by Károly Lőrentey on 2015-12-27. -// Copyright © 2016-2017 Károly Lőrentey. -// - -import XCTest -import Foundation -@testable import BigInt - -extension BigUInt.Kind: Equatable { - public static func ==(left: BigUInt.Kind, right: BigUInt.Kind) -> Bool { - switch (left, right) { - case let (.inline(l0, l1), .inline(r0, r1)): return l0 == r0 && l1 == r1 - case let (.slice(from: ls, to: le), .slice(from: rs, to: re)): return ls == rs && le == re - case (.array, .array): return true - default: return false - } - } -} - -class BigUIntTests: XCTestCase { - typealias Word = BigUInt.Word - - func check(_ value: BigUInt, _ kind: BigUInt.Kind?, _ words: [Word], file: StaticString = #file, line: UInt = #line) { - if let kind = kind { - XCTAssertEqual( - value.kind, kind, - "Mismatching kind: \(value.kind) vs. \(kind)", - file: file, line: line) - } - XCTAssertEqual( - Array(value.words), words, - "Mismatching words: \(value.words) vs. \(words)", - file: file, line: line) - XCTAssertEqual( - value.isZero, words.isEmpty, - "Mismatching isZero: \(value.isZero) vs. \(words.isEmpty)", - file: file, line: line) - XCTAssertEqual( - value.count, words.count, - "Mismatching count: \(value.count) vs. \(words.count)", - file: file, line: line) - for i in 0 ..< words.count { - XCTAssertEqual( - value[i], words[i], - "Mismatching word at index \(i): \(value[i]) vs. \(words[i])", - file: file, line: line) - } - for i in words.count ..< words.count + 10 { - XCTAssertEqual( - value[i], 0, - "Expected 0 word at index \(i), got \(value[i])", - file: file, line: line) - } - } - - func check(_ value: BigUInt?, _ kind: BigUInt.Kind?, _ words: [Word], file: StaticString = #file, line: UInt = #line) { - guard let value = value else { - XCTFail("Expected non-nil BigUInt", file: file, line: line) - return - } - check(value, kind, words, file: file, line: line) - } - - func testInit_WordBased() { - check(BigUInt(), .inline(0, 0), []) - - check(BigUInt(word: 0), .inline(0, 0), []) - check(BigUInt(word: 1), .inline(1, 0), [1]) - check(BigUInt(word: Word.max), .inline(Word.max, 0), [Word.max]) - - check(BigUInt(low: 0, high: 0), .inline(0, 0), []) - check(BigUInt(low: 0, high: 1), .inline(0, 1), [0, 1]) - check(BigUInt(low: 1, high: 0), .inline(1, 0), [1]) - check(BigUInt(low: 1, high: 2), .inline(1, 2), [1, 2]) - - check(BigUInt(words: []), .array, []) - check(BigUInt(words: [0, 0, 0, 0]), .array, []) - check(BigUInt(words: [1]), .array, [1]) - check(BigUInt(words: [1, 2, 3, 0, 0]), .array, [1, 2, 3]) - check(BigUInt(words: [0, 1, 2, 3, 4]), .array, [0, 1, 2, 3, 4]) - - check(BigUInt(words: [], from: 0, to: 0), .inline(0, 0), []) - check(BigUInt(words: [1, 2, 3, 4], from: 0, to: 4), .array, [1, 2, 3, 4]) - check(BigUInt(words: [1, 2, 3, 4], from: 0, to: 3), .slice(from: 0, to: 3), [1, 2, 3]) - check(BigUInt(words: [1, 2, 3, 4], from: 1, to: 4), .slice(from: 1, to: 4), [2, 3, 4]) - check(BigUInt(words: [1, 2, 3, 4], from: 0, to: 2), .inline(1, 2), [1, 2]) - check(BigUInt(words: [1, 2, 3, 4], from: 0, to: 1), .inline(1, 0), [1]) - check(BigUInt(words: [1, 2, 3, 4], from: 1, to: 1), .inline(0, 0), []) - check(BigUInt(words: [0, 0, 0, 1, 0, 0, 0, 2], from: 0, to: 4), .slice(from: 0, to: 4), [0, 0, 0, 1]) - check(BigUInt(words: [0, 0, 0, 1, 0, 0, 0, 2], from: 0, to: 3), .inline(0, 0), []) - check(BigUInt(words: [0, 0, 0, 1, 0, 0, 0, 2], from: 2, to: 6), .inline(0, 1), [0, 1]) - - check(BigUInt(words: [].lazy), .inline(0, 0), []) - check(BigUInt(words: [1].lazy), .inline(1, 0), [1]) - check(BigUInt(words: [1, 2].lazy), .inline(1, 2), [1, 2]) - check(BigUInt(words: [1, 2, 3].lazy), .array, [1, 2, 3]) - check(BigUInt(words: [1, 2, 3, 0, 0, 0, 0].lazy), .array, [1, 2, 3]) - - check(BigUInt(words: IteratorSequence([].makeIterator())), .inline(0, 0), []) - check(BigUInt(words: IteratorSequence([1].makeIterator())), .inline(1, 0), [1]) - check(BigUInt(words: IteratorSequence([1, 2].makeIterator())), .inline(1, 2), [1, 2]) - check(BigUInt(words: IteratorSequence([1, 2, 3].makeIterator())), .array, [1, 2, 3]) - check(BigUInt(words: IteratorSequence([1, 2, 3, 0, 0, 0, 0].makeIterator())), .array, [1, 2, 3]) - } - - func testInit_BinaryInteger() { - XCTAssertNil(BigUInt(exactly: -42)) - check(BigUInt(exactly: 0 as Int), .inline(0, 0), []) - check(BigUInt(exactly: 42 as Int), .inline(42, 0), [42]) - check(BigUInt(exactly: 43 as UInt), .inline(43, 0), [43]) - check(BigUInt(exactly: 44 as UInt8), .inline(44, 0), [44]) - check(BigUInt(exactly: BigUInt(words: [])), .inline(0, 0), []) - check(BigUInt(exactly: BigUInt(words: [1])), .inline(1, 0), [1]) - check(BigUInt(exactly: BigUInt(words: [1, 2])), .inline(1, 2), [1, 2]) - check(BigUInt(exactly: BigUInt(words: [1, 2, 3, 4])), .array, [1, 2, 3, 4]) - } - - func testInit_FloatingPoint() { - check(BigUInt(exactly: -0.0 as Float), nil, []) - check(BigUInt(exactly: -0.0 as Double), nil, []) - - XCTAssertNil(BigUInt(exactly: -42.0 as Float)) - XCTAssertNil(BigUInt(exactly: -42.0 as Double)) - - XCTAssertNil(BigUInt(exactly: 42.5 as Float)) - XCTAssertNil(BigUInt(exactly: 42.5 as Double)) - - check(BigUInt(exactly: 100 as Float), nil, [100]) - check(BigUInt(exactly: 100 as Double), nil, [100]) - - check(BigUInt(exactly: Float.greatestFiniteMagnitude), nil, - convertWords([0, 0xFFFFFF0000000000])) - - check(BigUInt(exactly: Double.greatestFiniteMagnitude), nil, - convertWords([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFFFFFFFFFFFFF800])) - - XCTAssertNil(BigUInt(exactly: Float.leastNormalMagnitude)) - XCTAssertNil(BigUInt(exactly: Double.leastNormalMagnitude)) - - XCTAssertNil(BigUInt(exactly: Float.infinity)) - XCTAssertNil(BigUInt(exactly: Double.infinity)) - - XCTAssertNil(BigUInt(exactly: Float.nan)) - XCTAssertNil(BigUInt(exactly: Double.nan)) - - check(BigUInt(0 as Float), nil, []) - check(BigUInt(Float.leastNonzeroMagnitude), nil, []) - check(BigUInt(Float.leastNormalMagnitude), nil, []) - check(BigUInt(0.5 as Float), nil, []) - check(BigUInt(1.5 as Float), nil, [1]) - check(BigUInt(42 as Float), nil, [42]) - check(BigUInt(Double(sign: .plus, exponent: 2 * Word.bitWidth, significand: 1.0)), - nil, [0, 0, 1]) - } - - func testInit_Buffer() { - func test(_ b: BigUInt, _ d: Array, file: StaticString = #file, line: UInt = #line) { - d.withUnsafeBytes { buffer in - let initialized = BigUInt(buffer) - XCTAssertEqual(initialized, b, file: file, line: line) - } - } - - // Positive integers - test(BigUInt(), []) - test(BigUInt(1), [0x01]) - test(BigUInt(2), [0x02]) - test(BigUInt(0x0102030405060708), [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08]) - test(BigUInt(0x01) << 64 + BigUInt(0x0203040506070809), [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 09]) - } - - func testConversionToFloatingPoint() { - func test(_ a: BigUInt, _ b: F, file: StaticString = #file, line: UInt = #line) - where F.RawExponent: FixedWidthInteger, F.RawSignificand: FixedWidthInteger { - let f = F(a) - XCTAssertEqual(f, b, file: file, line: line) - } - - for i in 0 ..< 100 { - test(BigUInt(i), Double(i)) - } - test(BigUInt(0x5A5A5A), 0x5A5A5A as Double) - test(BigUInt(1) << 64, 0x1p64 as Double) - test(BigUInt(0x5A5A5A) << 64, 0x5A5A5Ap64 as Double) - test(BigUInt(1) << 1023, 0x1p1023 as Double) - test(BigUInt(10) << 1020, 0xAp1020 as Double) - test(BigUInt(1) << 1024, Double.infinity) - test(BigUInt(words: convertWords([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFFFFFFFFFFFFF800])), - Double.greatestFiniteMagnitude) - test(BigUInt(UInt64.max), 0x1p64 as Double) - - for i in 0 ..< 100 { - test(BigUInt(i), Float(i)) - } - test(BigUInt(0x5A5A5A), 0x5A5A5A as Float) - test(BigUInt(1) << 64, 0x1p64 as Float) - test(BigUInt(0x5A5A5A) << 64, 0x5A5A5Ap64 as Float) - test(BigUInt(1) << 1023, 0x1p1023 as Float) - test(BigUInt(10) << 1020, 0xAp1020 as Float) - test(BigUInt(1) << 1024, Float.infinity) - test(BigUInt(words: convertWords([0, 0xFFFFFF0000000000])), - Float.greatestFiniteMagnitude) - - // Test rounding - test(BigUInt(0xFFFFFF0000000000 as UInt64), 0xFFFFFFp40 as Float) - test(BigUInt(0xFFFFFF7FFFFFFFFF as UInt64), 0xFFFFFFp40 as Float) - test(BigUInt(0xFFFFFF8000000000 as UInt64), 0x1p64 as Float) - test(BigUInt(0xFFFFFFFFFFFFFFFF as UInt64), 0x1p64 as Float) - - test(BigUInt(0xFFFFFE0000000000 as UInt64), 0xFFFFFEp40 as Float) - test(BigUInt(0xFFFFFE7FFFFFFFFF as UInt64), 0xFFFFFEp40 as Float) - test(BigUInt(0xFFFFFE8000000000 as UInt64), 0xFFFFFEp40 as Float) - test(BigUInt(0xFFFFFEFFFFFFFFFF as UInt64), 0xFFFFFEp40 as Float) - - test(BigUInt(0x8000010000000000 as UInt64), 0x800001p40 as Float) - test(BigUInt(0x8000017FFFFFFFFF as UInt64), 0x800001p40 as Float) - test(BigUInt(0x8000018000000000 as UInt64), 0x800002p40 as Float) - test(BigUInt(0x800001FFFFFFFFFF as UInt64), 0x800002p40 as Float) - - test(BigUInt(0x8000020000000000 as UInt64), 0x800002p40 as Float) - test(BigUInt(0x8000027FFFFFFFFF as UInt64), 0x800002p40 as Float) - test(BigUInt(0x8000028000000000 as UInt64), 0x800002p40 as Float) - test(BigUInt(0x800002FFFFFFFFFF as UInt64), 0x800002p40 as Float) - } - - func testInit_Misc() { - check(BigUInt(0), .inline(0, 0), []) - check(BigUInt(42), .inline(42, 0), [42]) - check(BigUInt(BigUInt(words: [1, 2, 3])), .array, [1, 2, 3]) - - check(BigUInt(truncatingIfNeeded: 0 as Int8), .inline(0, 0), []) - check(BigUInt(truncatingIfNeeded: 1 as Int8), .inline(1, 0), [1]) - check(BigUInt(truncatingIfNeeded: -1 as Int8), .inline(Word.max, 0), [Word.max]) - check(BigUInt(truncatingIfNeeded: BigUInt(words: [1, 2, 3])), .array, [1, 2, 3]) - - check(BigUInt(clamping: 0), .inline(0, 0), []) - check(BigUInt(clamping: -100), .inline(0, 0), []) - check(BigUInt(clamping: Word.max), .inline(Word.max, 0), [Word.max]) - } - - func testEnsureArray() { - var a = BigUInt() - a.ensureArray() - check(a, .array, []) - - a = BigUInt(word: 1) - a.ensureArray() - check(a, .array, [1]) - - a = BigUInt(low: 1, high: 2) - a.ensureArray() - check(a, .array, [1, 2]) - - a = BigUInt(words: [1, 2, 3, 4]) - a.ensureArray() - check(a, .array, [1, 2, 3, 4]) - - a = BigUInt(words: [1, 2, 3, 4, 5, 6], from: 1, to: 5) - a.ensureArray() - check(a, .array, [2, 3, 4, 5]) - } - - func testCapacity() { - XCTAssertEqual(BigUInt(low: 1, high: 2).capacity, 0) - XCTAssertEqual(BigUInt(words: 1 ..< 10).extract(2 ..< 5).capacity, 0) - var words: [Word] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] - words.reserveCapacity(100) - XCTAssertEqual(BigUInt(words: words).capacity, 100) - } - - func testReserveCapacity() { - var a = BigUInt() - a.reserveCapacity(100) - check(a, .array, []) - XCTAssertEqual(a.capacity, 100) - - a = BigUInt(word: 1) - a.reserveCapacity(100) - check(a, .array, [1]) - XCTAssertEqual(a.capacity, 100) - - a = BigUInt(low: 1, high: 2) - a.reserveCapacity(100) - check(a, .array, [1, 2]) - XCTAssertEqual(a.capacity, 100) - - a = BigUInt(words: [1, 2, 3, 4]) - a.reserveCapacity(100) - check(a, .array, [1, 2, 3, 4]) - XCTAssertEqual(a.capacity, 100) - - a = BigUInt(words: [1, 2, 3, 4, 5, 6], from: 1, to: 5) - a.reserveCapacity(100) - check(a, .array, [2, 3, 4, 5]) - XCTAssertEqual(a.capacity, 100) - } - - func testLoad() { - var a: BigUInt = 0 - a.reserveCapacity(100) - - a.load(BigUInt(low: 1, high: 2)) - check(a, .array, [1, 2]) - XCTAssertEqual(a.capacity, 100) - - a.load(BigUInt(words: [1, 2, 3, 4, 5, 6])) - check(a, .array, [1, 2, 3, 4, 5, 6]) - XCTAssertEqual(a.capacity, 100) - - a.clear() - check(a, .array, []) - XCTAssertEqual(a.capacity, 100) - } - - func testInitFromLiterals() { - check(0, .inline(0, 0), []) - check(42, .inline(42, 0), [42]) - check("42", .inline(42, 0), [42]) - - check("1512366075204170947332355369683137040", - .inline(0xFEDCBA9876543210, 0x0123456789ABCDEF), - [0xFEDCBA9876543210, 0x0123456789ABCDEF]) - - // I have no idea how to exercise these in the wild - check(BigUInt(unicodeScalarLiteral: UnicodeScalar(52)), .inline(4, 0), [4]) - check(BigUInt(extendedGraphemeClusterLiteral: "4"), .inline(4, 0), [4]) - } - - func testSubscriptingGetter() { - let a = BigUInt(words: [1, 2]) - XCTAssertEqual(a[0], 1) - XCTAssertEqual(a[1], 2) - XCTAssertEqual(a[2], 0) - XCTAssertEqual(a[3], 0) - XCTAssertEqual(a[10000], 0) - - let b = BigUInt(low: 1, high: 2) - XCTAssertEqual(b[0], 1) - XCTAssertEqual(b[1], 2) - XCTAssertEqual(b[2], 0) - XCTAssertEqual(b[3], 0) - XCTAssertEqual(b[10000], 0) - } - - func testSubscriptingSetter() { - var a = BigUInt() - - check(a, .inline(0, 0), []) - a[10] = 0 - check(a, .inline(0, 0), []) - a[0] = 42 - check(a, .inline(42, 0), [42]) - a[10] = 23 - check(a, .array, [42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23]) - a[0] = 0 - check(a, .array, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23]) - a[10] = 0 - check(a, .array, []) - - a = BigUInt(words: [0, 1, 2, 3, 4, 5, 6], from: 1, to: 5) - a[2] = 42 - check(a, .array, [1, 2, 42, 4]) - } - - func testSlice() { - let a = BigUInt(words: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) - check(a.extract(3 ..< 6), .slice(from: 3, to: 6), [3, 4, 5]) - check(a.extract(3 ..< 5), .inline(3, 4), [3, 4]) - check(a.extract(3 ..< 4), .inline(3, 0), [3]) - check(a.extract(3 ..< 3), .inline(0, 0), []) - check(a.extract(0 ..< 100), .array, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) - check(a.extract(100 ..< 200), .inline(0, 0), []) - - let b = BigUInt(low: 1, high: 2) - check(b.extract(0 ..< 2), .inline(1, 2), [1, 2]) - check(b.extract(0 ..< 1), .inline(1, 0), [1]) - check(b.extract(1 ..< 2), .inline(2, 0), [2]) - check(b.extract(1 ..< 1), .inline(0, 0), []) - check(b.extract(0 ..< 100), .inline(1, 2), [1, 2]) - check(b.extract(100 ..< 200), .inline(0, 0), []) - - let c = BigUInt(words: [1, 0, 0, 0, 2, 0, 0, 0, 3, 4, 5, 0, 0, 6, 0, 0, 0, 7]) - check(c.extract(0 ..< 4), .inline(1, 0), [1]) - check(c.extract(1 ..< 5), .slice(from: 1, to: 5), [0, 0, 0, 2]) - check(c.extract(1 ..< 8), .slice(from: 1, to: 5), [0, 0, 0, 2]) - check(c.extract(6 ..< 12), .slice(from: 6, to: 11), [0, 0, 3, 4, 5]) - check(c.extract(4 ..< 7), .inline(2, 0), [2]) - - let d = c.extract(3 ..< 14) - // 0 1 2 3 4 5 6 7 8 9 10 - check(d, .slice(from: 3, to: 14), [0, 2, 0, 0, 0, 3, 4, 5, 0, 0, 6]) - check(d.extract(1 ..< 5), .inline(2, 0), [2]) - check(d.extract(0 ..< 3), .inline(0, 2), [0, 2]) - check(d.extract(1 ..< 6), .slice(from: 4, to: 9), [2, 0, 0, 0, 3]) - check(d.extract(7 ..< 1000), .slice(from: 10, to: 14), [5, 0, 0, 6]) - check(d.extract(10 ..< 1000), .inline(6, 0), [6]) - check(d.extract(11 ..< 1000), .inline(0, 0), []) - } - - func testSigns() { - XCTAssertFalse(BigUInt.isSigned) - - XCTAssertEqual(BigUInt().signum(), 0) - XCTAssertEqual(BigUInt(words: []).signum(), 0) - XCTAssertEqual(BigUInt(words: [0, 1, 2]).signum(), 1) - XCTAssertEqual(BigUInt(word: 42).signum(), 1) - } - - func testBits() { - let indices: Set = [0, 13, 59, 64, 79, 130] - var value: BigUInt = 0 - for i in indices { - value[bitAt: i] = true - } - for i in 0 ..< 300 { - XCTAssertEqual(value[bitAt: i], indices.contains(i)) - } - check(value, nil, convertWords([0x0800000000002001, 0x8001, 0x04])) - for i in indices { - value[bitAt: i] = false - } - check(value, nil, []) - } - - func testStrideableRequirements() { - XCTAssertEqual(BigUInt(10), BigUInt(4).advanced(by: BigInt(6))) - XCTAssertEqual(BigUInt(4), BigUInt(10).advanced(by: BigInt(-6))) - XCTAssertEqual(BigInt(6), BigUInt(4).distance(to: 10)) - XCTAssertEqual(BigInt(-6), BigUInt(10).distance(to: 4)) - } - - func testRightShift_ByWord() { - var a = BigUInt() - a.shiftRight(byWords: 1) - check(a, .inline(0, 0), []) - - a = BigUInt(low: 1, high: 2) - a.shiftRight(byWords: 0) - check(a, .inline(1, 2), [1, 2]) - - a = BigUInt(low: 1, high: 2) - a.shiftRight(byWords: 1) - check(a, .inline(2, 0), [2]) - - a = BigUInt(low: 1, high: 2) - a.shiftRight(byWords: 2) - check(a, .inline(0, 0), []) - - a = BigUInt(low: 1, high: 2) - a.shiftRight(byWords: 10) - check(a, .inline(0, 0), []) - - - a = BigUInt(words: [0, 1, 2, 3, 4]) - a.shiftRight(byWords: 1) - check(a, .array, [1, 2, 3, 4]) - - a = BigUInt(words: [0, 1, 2, 3, 4]) - a.shiftRight(byWords: 2) - check(a, .array, [2, 3, 4]) - - a = BigUInt(words: [0, 1, 2, 3, 4]) - a.shiftRight(byWords: 5) - check(a, .array, []) - - a = BigUInt(words: [0, 1, 2, 3, 4]) - a.shiftRight(byWords: 100) - check(a, .array, []) - - - a = BigUInt(words: [0, 1, 2, 3, 4, 5, 6], from: 1, to: 6) - check(a, .slice(from: 1, to: 6), [1, 2, 3, 4, 5]) - a.shiftRight(byWords: 1) - check(a, .slice(from: 2, to: 6), [2, 3, 4, 5]) - - a = BigUInt(words: [0, 1, 2, 3, 4, 5, 6], from: 1, to: 6) - a.shiftRight(byWords: 2) - check(a, .slice(from: 3, to: 6), [3, 4, 5]) - - a = BigUInt(words: [0, 1, 2, 3, 4, 5, 6], from: 1, to: 6) - a.shiftRight(byWords: 3) - check(a, .inline(4, 5), [4, 5]) - - a = BigUInt(words: [0, 1, 2, 3, 4, 5, 6], from: 1, to: 6) - a.shiftRight(byWords: 4) - check(a, .inline(5, 0), [5]) - - a = BigUInt(words: [0, 1, 2, 3, 4, 5, 6], from: 1, to: 6) - a.shiftRight(byWords: 5) - check(a, .inline(0, 0), []) - - a = BigUInt(words: [0, 1, 2, 3, 4, 5, 6], from: 1, to: 6) - a.shiftRight(byWords: 10) - check(a, .inline(0, 0), []) - } - - func testLeftShift_ByWord() { - var a = BigUInt() - a.shiftLeft(byWords: 1) - check(a, .inline(0, 0), []) - - a = BigUInt(word: 1) - a.shiftLeft(byWords: 0) - check(a, .inline(1, 0), [1]) - - a = BigUInt(word: 1) - a.shiftLeft(byWords: 1) - check(a, .inline(0, 1), [0, 1]) - - a = BigUInt(word: 1) - a.shiftLeft(byWords: 2) - check(a, .array, [0, 0, 1]) - - a = BigUInt(low: 1, high: 2) - a.shiftLeft(byWords: 1) - check(a, .array, [0, 1, 2]) - - a = BigUInt(low: 1, high: 2) - a.shiftLeft(byWords: 2) - check(a, .array, [0, 0, 1, 2]) - - a = BigUInt(words: [1, 2, 3, 4, 5, 6]) - a.shiftLeft(byWords: 1) - check(a, .array, [0, 1, 2, 3, 4, 5, 6]) - - a = BigUInt(words: [1, 2, 3, 4, 5, 6]) - a.shiftLeft(byWords: 10) - check(a, .array, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6]) - - a = BigUInt(words: [0, 1, 2, 3, 4, 5, 6], from: 2, to: 6) - a.shiftLeft(byWords: 1) - check(a, .array, [0, 2, 3, 4, 5]) - - a = BigUInt(words: [0, 1, 2, 3, 4, 5, 6], from: 2, to: 6) - a.shiftLeft(byWords: 3) - check(a, .array, [0, 0, 0, 2, 3, 4, 5]) - } - - func testSplit() { - let a = BigUInt(words: [0, 1, 2, 3]) - XCTAssertEqual(a.split.low, BigUInt(words: [0, 1])) - XCTAssertEqual(a.split.high, BigUInt(words: [2, 3])) - } - - func testLowHigh() { - let a = BigUInt(words: [0, 1, 2, 3]) - check(a.low, .inline(0, 1), [0, 1]) - check(a.high, .inline(2, 3), [2, 3]) - check(a.low.low, .inline(0, 0), []) - check(a.low.high, .inline(1, 0), [1]) - check(a.high.low, .inline(2, 0), [2]) - check(a.high.high, .inline(3, 0), [3]) - - let b = BigUInt(words: [0, 1, 2, 3, 4, 5]) - - let bl = b.low - check(bl, .slice(from: 0, to: 3), [0, 1, 2]) - let bh = b.high - check(bh, .slice(from: 3, to: 6), [3, 4, 5]) - - let bll = bl.low - check(bll, .inline(0, 1), [0, 1]) - let blh = bl.high - check(blh, .inline(2, 0), [2]) - let bhl = bh.low - check(bhl, .inline(3, 4), [3, 4]) - let bhh = bh.high - check(bhh, .inline(5, 0), [5]) - - let blhl = bll.low - check(blhl, .inline(0, 0), []) - let blhh = bll.high - check(blhh, .inline(1, 0), [1]) - let bhhl = bhl.low - check(bhhl, .inline(3, 0), [3]) - let bhhh = bhl.high - check(bhhh, .inline(4, 0), [4]) - } - - func testComparison() { - XCTAssertEqual(BigUInt(words: [1, 2, 3]), BigUInt(words: [1, 2, 3])) - XCTAssertNotEqual(BigUInt(words: [1, 2]), BigUInt(words: [1, 2, 3])) - XCTAssertNotEqual(BigUInt(words: [1, 2, 3]), BigUInt(words: [1, 3, 3])) - XCTAssertEqual(BigUInt(words: [1, 2, 3, 4, 5, 6]).low.high, BigUInt(words: [3])) - - XCTAssertTrue(BigUInt(words: [1, 2]) < BigUInt(words: [1, 2, 3])) - XCTAssertTrue(BigUInt(words: [1, 2, 2]) < BigUInt(words: [1, 2, 3])) - XCTAssertFalse(BigUInt(words: [1, 2, 3]) < BigUInt(words: [1, 2, 3])) - XCTAssertTrue(BigUInt(words: [3, 3]) < BigUInt(words: [1, 2, 3, 4, 5, 6]).extract(2 ..< 4)) - XCTAssertTrue(BigUInt(words: [1, 2, 3, 4, 5, 6]).low.high < BigUInt(words: [3, 5])) - } - - func testHashing() { - var hashes: [Int] = [] - hashes.append(BigUInt(words: []).hashValue) - hashes.append(BigUInt(words: [1]).hashValue) - hashes.append(BigUInt(words: [2]).hashValue) - hashes.append(BigUInt(words: [0, 1]).hashValue) - hashes.append(BigUInt(words: [1, 1]).hashValue) - hashes.append(BigUInt(words: [1, 2]).hashValue) - hashes.append(BigUInt(words: [2, 1]).hashValue) - hashes.append(BigUInt(words: [2, 2]).hashValue) - hashes.append(BigUInt(words: [1, 2, 3, 4, 5]).hashValue) - hashes.append(BigUInt(words: [5, 4, 3, 2, 1]).hashValue) - hashes.append(BigUInt(words: [Word.max]).hashValue) - hashes.append(BigUInt(words: [Word.max, Word.max]).hashValue) - hashes.append(BigUInt(words: [Word.max, Word.max, Word.max]).hashValue) - hashes.append(BigUInt(words: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]).hashValue) - XCTAssertEqual(hashes.count, Set(hashes).count) - } - - func checkData(_ bytes: [UInt8], _ value: BigUInt, file: StaticString = #file, line: UInt = #line) { - XCTAssertEqual(BigUInt(Data(bytes)), value, file: file, line: line) - XCTAssertEqual(bytes.withUnsafeBytes { buffer in BigUInt(buffer) }, value, file: file, line: line) - } - - func testConversionFromBytes() { - checkData([], 0) - checkData([0], 0) - checkData([0, 0, 0, 0, 0, 0, 0, 0], 0) - checkData([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 0) - checkData([1], 1) - checkData([2], 2) - checkData([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], 1) - checkData([0x01, 0x02, 0x03, 0x04, 0x05], 0x0102030405) - checkData([0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08], 0x0102030405060708) - checkData([0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A], - BigUInt(0x0102) << 64 + BigUInt(0x030405060708090A)) - checkData([0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], - BigUInt(1) << 80) - checkData([0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10], - BigUInt(0x0102030405060708) << 64 + BigUInt(0x090A0B0C0D0E0F10)) - checkData([0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11], - ((BigUInt(1) << 128) as BigUInt) + BigUInt(0x0203040506070809) << 64 + BigUInt(0x0A0B0C0D0E0F1011)) - } - - func testConversionToData() { - func test(_ b: BigUInt, _ d: Array, file: StaticString = #file, line: UInt = #line) { - let expected = Data(d) - let actual = b.serialize() - XCTAssertEqual(actual, expected, file: file, line: line) - XCTAssertEqual(BigUInt(actual), b, file: file, line: line) - } - - test(BigUInt(), []) - test(BigUInt(1), [0x01]) - test(BigUInt(2), [0x02]) - test(BigUInt(0x0102030405060708), [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08]) - test(BigUInt(0x01) << 64 + BigUInt(0x0203040506070809), [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09]) - } - - func testCodable() { - func test(_ a: BigUInt, file: StaticString = #file, line: UInt = #line) { - do { - let json = try JSONEncoder().encode(a) - print(String(data: json, encoding: .utf8)!) - let b = try JSONDecoder().decode(BigUInt.self, from: json) - XCTAssertEqual(a, b, file: file, line: line) - } - catch let error { - XCTFail("Error thrown: \(error.localizedDescription)", file: file, line: line) - } - } - test(0) - test(1) - test(0x0102030405060708) - test(BigUInt(1) << 64) - test(BigUInt(words: [1, 2, 3, 4, 5, 6, 7])) - - XCTAssertThrowsError(try JSONDecoder().decode(BigUInt.self, from: "[\"*\", 1]".data(using: .utf8)!)) { error in - guard let error = error as? DecodingError else { XCTFail("Expected a decoding error"); return } - guard case .dataCorrupted(let context) = error else { XCTFail("Expected a dataCorrupted error"); return } - XCTAssertEqual(context.debugDescription, "Invalid big integer sign") - } - XCTAssertThrowsError(try JSONDecoder().decode(BigUInt.self, from: "[\"-\", 1]".data(using: .utf8)!)) { error in - guard let error = error as? DecodingError else { XCTFail("Expected a decoding error"); return } - guard case .dataCorrupted(let context) = error else { XCTFail("Expected a dataCorrupted error"); return } - XCTAssertEqual(context.debugDescription, "BigUInt cannot hold a negative value") - } - } - - func testAddition() { - XCTAssertEqual(BigUInt(0) + BigUInt(0), BigUInt(0)) - XCTAssertEqual(BigUInt(0) + BigUInt(Word.max), BigUInt(Word.max)) - XCTAssertEqual(BigUInt(Word.max) + BigUInt(1), BigUInt(words: [0, 1])) - - check(BigUInt(3) + BigUInt(42), .inline(45, 0), [45]) - check(BigUInt(3) + BigUInt(42), .inline(45, 0), [45]) - - check(0 + BigUInt(Word.max), .inline(Word.max, 0), [Word.max]) - check(1 + BigUInt(Word.max), .inline(0, 1), [0, 1]) - check(BigUInt(low: 0, high: 1) + BigUInt(low: 3, high: 4), .inline(3, 5), [3, 5]) - check(BigUInt(low: 3, high: 5) + BigUInt(low: 0, high: Word.max), .array, [3, 4, 1]) - check(BigUInt(words: [3, 4, 1]) + BigUInt(low: 0, high: Word.max), .array, [3, 3, 2]) - check(BigUInt(words: [3, 3, 2]) + 2, .array, [5, 3, 2]) - check(BigUInt(words: [Word.max - 5, Word.max, 4, Word.max]).addingWord(6), .array, [0, 0, 5, Word.max]) - - var b = BigUInt(words: [Word.max, 2, Word.max]) - b.increment() - check(b, .array, [0, 3, Word.max]) - } - - func testShiftedAddition() { - var b = BigUInt() - b.add(1, shiftedBy: 1) - check(b, .inline(0, 1), [0, 1]) - - b.add(2, shiftedBy: 3) - check(b, .array, [0, 1, 0, 2]) - - b.add(BigUInt(Word.max), shiftedBy: 1) - check(b, .array, [0, 0, 1, 2]) - } - - func testSubtraction() { - var a1 = BigUInt(words: [1, 2, 3, 4]) - XCTAssertEqual(false, a1.subtractWordReportingOverflow(3, shiftedBy: 1)) - check(a1, .array, [1, Word.max, 2, 4]) - - let (diff, overflow) = BigUInt(words: [1, 2, 3, 4]).subtractingWordReportingOverflow(2) - XCTAssertEqual(false, overflow) - check(diff, .array, [Word.max, 1, 3, 4]) - - var a2 = BigUInt(words: [1, 2, 3, 4]) - XCTAssertEqual(true, a2.subtractWordReportingOverflow(5, shiftedBy: 3)) - check(a2, .array, [1, 2, 3, Word.max]) - - var a3 = BigUInt(words: [1, 2, 3, 4]) - a3.subtractWord(4, shiftedBy: 3) - check(a3, .array, [1, 2, 3]) - - var a4 = BigUInt(words: [1, 2, 3, 4]) - a4.decrement() - check(a4, .array, [0, 2, 3, 4]) - a4.decrement() - check(a4, .array, [Word.max, 1, 3, 4]) - - check(BigUInt(words: [1, 2, 3, 4]).subtractingWord(5), - .array, [Word.max - 3, 1, 3, 4]) - - check(BigUInt(0) - BigUInt(0), .inline(0, 0), []) - - var b = BigUInt(words: [1, 2, 3, 4]) - XCTAssertEqual(false, b.subtractReportingOverflow(BigUInt(words: [0, 1, 1, 1]))) - check(b, .array, [1, 1, 2, 3]) - - let b1 = BigUInt(words: [1, 1, 2, 3]).subtractingReportingOverflow(BigUInt(words: [1, 1, 3, 3])) - XCTAssertEqual(true, b1.overflow) - check(b1.partialValue, .array, [0, 0, Word.max, Word.max]) - - let b2 = BigUInt(words: [0, 0, 1]) - BigUInt(words: [1]) - check(b2, .array, [Word.max, Word.max]) - - var b3 = BigUInt(words: [1, 0, 0, 1]) - b3 -= 2 - check(b3, .array, [Word.max, Word.max, Word.max]) - - check(BigUInt(42) - BigUInt(23), .inline(19, 0), [19]) - } - - func testMultiplyByWord() { - check(BigUInt(words: [1, 2, 3, 4]).multiplied(byWord: 0), .inline(0, 0), []) - check(BigUInt(words: [1, 2, 3, 4]).multiplied(byWord: 2), .array, [2, 4, 6, 8]) - - let full = Word.max - - check(BigUInt(words: [full, 0, full, 0, full]).multiplied(byWord: 2), - .array, [full - 1, 1, full - 1, 1, full - 1, 1]) - - check(BigUInt(words: [full, full, full]).multiplied(byWord: 2), - .array, [full - 1, full, full, 1]) - - check(BigUInt(words: [full, full, full]).multiplied(byWord: full), - .array, [1, full, full, full - 1]) - - check(BigUInt("11111111111111111111111111111111", radix: 16)!.multiplied(byWord: 15), - .array, convertWords([UInt64.max, UInt64.max])) - - check(BigUInt("11111111111111111111111111111112", radix: 16)!.multiplied(byWord: 15), - .array, convertWords([0xE, 0, 0x1])) - - check(BigUInt(low: 1, high: 2).multiplied(byWord: 3), .inline(3, 6), [3, 6]) - } - - func testMultiplication() { - func test() { - check(BigUInt(low: 1, high: 1) * BigUInt(word: 3), .inline(3, 3), [3, 3]) - check(BigUInt(word: 4) * BigUInt(low: 1, high: 2), .inline(4, 8), [4, 8]) - - XCTAssertEqual( - BigUInt(words: [1, 2, 3, 4]) * BigUInt(), - BigUInt()) - XCTAssertEqual( - BigUInt() * BigUInt(words: [1, 2, 3, 4]), - BigUInt()) - XCTAssertEqual( - BigUInt(words: [1, 2, 3, 4]) * BigUInt(words: [2]), - BigUInt(words: [2, 4, 6, 8])) - XCTAssertEqual( - BigUInt(words: [1, 2, 3, 4]).multiplied(by: BigUInt(words: [2])), - BigUInt(words: [2, 4, 6, 8])) - XCTAssertEqual( - BigUInt(words: [2]) * BigUInt(words: [1, 2, 3, 4]), - BigUInt(words: [2, 4, 6, 8])) - XCTAssertEqual( - BigUInt(words: [1, 2, 3, 4]) * BigUInt(words: [0, 1]), - BigUInt(words: [0, 1, 2, 3, 4])) - XCTAssertEqual( - BigUInt(words: [0, 1]) * BigUInt(words: [1, 2, 3, 4]), - BigUInt(words: [0, 1, 2, 3, 4])) - XCTAssertEqual( - BigUInt(words: [4, 3, 2, 1]) * BigUInt(words: [1, 2, 3, 4]), - BigUInt(words: [4, 11, 20, 30, 20, 11, 4])) - // 999 * 99 = 98901 - XCTAssertEqual( - BigUInt(words: [Word.max, Word.max, Word.max]) * BigUInt(words: [Word.max, Word.max]), - BigUInt(words: [1, 0, Word.max, Word.max - 1, Word.max])) - XCTAssertEqual( - BigUInt(words: [1, 2]) * BigUInt(words: [2, 1]), - BigUInt(words: [2, 5, 2])) - - var b = BigUInt("2637AB28", radix: 16)! - b *= BigUInt("164B", radix: 16)! - XCTAssertEqual(b, BigUInt("353FB0494B8", radix: 16)) - - XCTAssertEqual(BigUInt("16B60", radix: 16)! * BigUInt("33E28", radix: 16)!, BigUInt("49A5A0700", radix: 16)!) - } - - test() - // Disable brute force multiplication. - let limit = BigUInt.directMultiplicationLimit - BigUInt.directMultiplicationLimit = 0 - defer { BigUInt.directMultiplicationLimit = limit } - - test() - } - - func testDivision() { - func test(_ a: [Word], _ b: [Word], file: StaticString = #file, line: UInt = #line) { - let x = BigUInt(words: a) - let y = BigUInt(words: b) - let (div, mod) = x.quotientAndRemainder(dividingBy: y) - if mod >= y { - XCTFail("x:\(x) = div:\(div) * y:\(y) + mod:\(mod)", file: file, line: line) - } - if div * y + mod != x { - XCTFail("x:\(x) = div:\(div) * y:\(y) + mod:\(mod)", file: file, line: line) - } - - let shift = y.leadingZeroBitCount - let norm = y << shift - var rem = x - rem.formRemainder(dividingBy: norm, normalizedBy: shift) - XCTAssertEqual(rem, mod, file: file, line: line) - } - - // These cases exercise all code paths in the division when Word is UInt8 or UInt64. - test([], [1]) - test([1], [1]) - test([1], [2]) - test([2], [1]) - test([], [0, 1]) - test([1], [0, 1]) - test([0, 1], [0, 1]) - test([0, 0, 1], [0, 1]) - test([0, 0, 1], [1, 1]) - test([0, 0, 1], [3, 1]) - test([0, 0, 1], [75, 1]) - test([0, 0, 0, 1], [0, 1]) - test([2, 4, 6, 8], [1, 2]) - test([2, 3, 4, 5], [4, 5]) - test([Word.max, Word.max - 1, Word.max], [Word.max, Word.max]) - test([0, Word.max, Word.max - 1], [Word.max, Word.max]) - test([0, 0, 0, 0, 0, Word.max / 2 + 1, Word.max / 2], [1, 0, 0, Word.max / 2 + 1]) - test([0, Word.max - 1, Word.max / 2 + 1], [Word.max, Word.max / 2 + 1]) - test([0, 0, 0x41 << Word(Word.bitWidth - 8)], [Word.max, 1 << Word(Word.bitWidth - 1)]) - - XCTAssertEqual(BigUInt(328) / BigUInt(21), BigUInt(15)) - XCTAssertEqual(BigUInt(328) % BigUInt(21), BigUInt(13)) - - var a = BigUInt(328) - a /= 21 - XCTAssertEqual(a, 15) - a %= 7 - XCTAssertEqual(a, 1) - - #if false - for x0 in (0 ... Int(Word.max)) { - for x1 in (0 ... Int(Word.max)).reverse() { - for y0 in (0 ... Int(Word.max)).reverse() { - for y1 in (1 ... Int(Word.max)).reverse() { - for x2 in (1 ... y1).reverse() { - test( - [Word(x0), Word(x1), Word(x2)], - [Word(y0), Word(y1)]) - } - } - } - } - } - #endif - } - - func testFactorial() { - let power = 10 - var forward = BigUInt(1) - for i in 1 ..< (1 << power) { - forward *= BigUInt(i) - } - print("\(1 << power - 1)! = \(forward) [\(forward.count)]") - var backward = BigUInt(1) - for i in (1 ..< (1 << power)).reversed() { - backward *= BigUInt(i) - } - - func balancedFactorial(level: Int, offset: Int) -> BigUInt { - if level == 0 { - return BigUInt(offset == 0 ? 1 : offset) - } - let a = balancedFactorial(level: level - 1, offset: 2 * offset) - let b = balancedFactorial(level: level - 1, offset: 2 * offset + 1) - return a * b - } - let balanced = balancedFactorial(level: power, offset: 0) - - XCTAssertEqual(backward, forward) - XCTAssertEqual(balanced, forward) - - var remaining = balanced - for i in 1 ..< (1 << power) { - let (div, mod) = remaining.quotientAndRemainder(dividingBy: BigUInt(i)) - XCTAssertEqual(mod, 0) - remaining = div - } - XCTAssertEqual(remaining, 1) - } - - func testExponentiation() { - XCTAssertEqual(BigUInt(0).power(0), BigUInt(1)) - XCTAssertEqual(BigUInt(0).power(1), BigUInt(0)) - - XCTAssertEqual(BigUInt(1).power(0), BigUInt(1)) - XCTAssertEqual(BigUInt(1).power(1), BigUInt(1)) - XCTAssertEqual(BigUInt(1).power(-1), BigUInt(1)) - XCTAssertEqual(BigUInt(1).power(-2), BigUInt(1)) - XCTAssertEqual(BigUInt(1).power(-3), BigUInt(1)) - XCTAssertEqual(BigUInt(1).power(-4), BigUInt(1)) - - XCTAssertEqual(BigUInt(2).power(0), BigUInt(1)) - XCTAssertEqual(BigUInt(2).power(1), BigUInt(2)) - XCTAssertEqual(BigUInt(2).power(2), BigUInt(4)) - XCTAssertEqual(BigUInt(2).power(3), BigUInt(8)) - XCTAssertEqual(BigUInt(2).power(-1), BigUInt(0)) - XCTAssertEqual(BigUInt(2).power(-2), BigUInt(0)) - XCTAssertEqual(BigUInt(2).power(-3), BigUInt(0)) - - XCTAssertEqual(BigUInt(3).power(0), BigUInt(1)) - XCTAssertEqual(BigUInt(3).power(1), BigUInt(3)) - XCTAssertEqual(BigUInt(3).power(2), BigUInt(9)) - XCTAssertEqual(BigUInt(3).power(3), BigUInt(27)) - XCTAssertEqual(BigUInt(3).power(-1), BigUInt(0)) - XCTAssertEqual(BigUInt(3).power(-2), BigUInt(0)) - - XCTAssertEqual((BigUInt(1) << 256).power(0), BigUInt(1)) - XCTAssertEqual((BigUInt(1) << 256).power(1), BigUInt(1) << 256) - XCTAssertEqual((BigUInt(1) << 256).power(2), BigUInt(1) << 512) - - XCTAssertEqual(BigUInt(0).power(577), BigUInt(0)) - XCTAssertEqual(BigUInt(1).power(577), BigUInt(1)) - XCTAssertEqual(BigUInt(2).power(577), BigUInt(1) << 577) - } - - func testModularExponentiation() { - XCTAssertEqual(BigUInt(2).power(11, modulus: 1), 0) - XCTAssertEqual(BigUInt(2).power(11, modulus: 1000), 48) - - func test(a: BigUInt, p: BigUInt, file: StaticString = #file, line: UInt = #line) { - // For all primes p and integers a, a % p == a^p % p. (Fermat's Little Theorem) - let x = a % p - let y = x.power(p, modulus: p) - XCTAssertEqual(x, y, file: file, line: line) - } - - // Here are some primes - - let m61 = (BigUInt(1) << 61) - BigUInt(1) - let m127 = (BigUInt(1) << 127) - BigUInt(1) - let m521 = (BigUInt(1) << 521) - BigUInt(1) - - test(a: 2, p: m127) - test(a: BigUInt(1) << 42, p: m127) - test(a: BigUInt(1) << 42 + BigUInt(1), p: m127) - test(a: m61, p: m127) - test(a: m61 + 1, p: m127) - test(a: m61, p: m521) - test(a: m61 + 1, p: m521) - test(a: m127, p: m521) - } - - func testBitWidth() { - XCTAssertEqual(BigUInt(0).bitWidth, 0) - XCTAssertEqual(BigUInt(1).bitWidth, 1) - XCTAssertEqual(BigUInt(Word.max).bitWidth, Word.bitWidth) - XCTAssertEqual(BigUInt(words: [Word.max, 1]).bitWidth, Word.bitWidth + 1) - XCTAssertEqual(BigUInt(words: [2, 12]).bitWidth, Word.bitWidth + 4) - XCTAssertEqual(BigUInt(words: [1, Word.max]).bitWidth, 2 * Word.bitWidth) - - XCTAssertEqual(BigUInt(0).leadingZeroBitCount, 0) - XCTAssertEqual(BigUInt(1).leadingZeroBitCount, Word.bitWidth - 1) - XCTAssertEqual(BigUInt(Word.max).leadingZeroBitCount, 0) - XCTAssertEqual(BigUInt(words: [Word.max, 1]).leadingZeroBitCount, Word.bitWidth - 1) - XCTAssertEqual(BigUInt(words: [14, Word.max]).leadingZeroBitCount, 0) - - XCTAssertEqual(BigUInt(0).trailingZeroBitCount, 0) - XCTAssertEqual(BigUInt((1 as Word) << (Word.bitWidth - 1)).trailingZeroBitCount, Word.bitWidth - 1) - XCTAssertEqual(BigUInt(Word.max).trailingZeroBitCount, 0) - XCTAssertEqual(BigUInt(words: [0, 1]).trailingZeroBitCount, Word.bitWidth) - XCTAssertEqual(BigUInt(words: [0, 1 << Word(Word.bitWidth - 1)]).trailingZeroBitCount, 2 * Word.bitWidth - 1) - } - - func testBitwise() { - let a = BigUInt("1234567890ABCDEF13579BDF2468ACE", radix: 16)! - let b = BigUInt("ECA8642FDB97531FEDCBA0987654321", radix: 16)! - - // a = 01234567890ABCDEF13579BDF2468ACE - // b = 0ECA8642FDB97531FEDCBA0987654321 - XCTAssertEqual(String(~a, radix: 16), "fedcba9876f543210eca86420db97531") - XCTAssertEqual(String(a | b, radix: 16), "febc767fdbbfdfffffdfbbdf767cbef") - XCTAssertEqual(String(a & b, radix: 16), "2044289083410f014380982440200") - XCTAssertEqual(String(a ^ b, radix: 16), "fe9c32574b3c9ef0fe9c3b47523c9ef") - - let ffff = BigUInt(words: Array(repeating: Word.max, count: 30)) - let not = ~ffff - let zero = BigUInt() - XCTAssertEqual(not, zero) - XCTAssertEqual(Array((~ffff).words), []) - XCTAssertEqual(a | ffff, ffff) - XCTAssertEqual(a | 0, a) - XCTAssertEqual(a & a, a) - XCTAssertEqual(a & 0, 0) - XCTAssertEqual(a & ffff, a) - XCTAssertEqual(~(a | b), (~a & ~b)) - XCTAssertEqual(~(a & b), (~a | ~b).extract(..<(a&b).count)) - XCTAssertEqual(a ^ a, 0) - XCTAssertEqual((a ^ b) ^ b, a) - XCTAssertEqual((a ^ b) ^ a, b) - - var z = a * b - z |= a - z &= b - z ^= ffff - XCTAssertEqual(z, (((a * b) | a) & b) ^ ffff) - } - - func testLeftShifts() { - let sample = BigUInt("123456789ABCDEF01234567891631832727633", radix: 16)! - - var a = sample - - a <<= 0 - XCTAssertEqual(a, sample) - - a = sample - a <<= 1 - XCTAssertEqual(a, 2 * sample) - - a = sample - a <<= Word.bitWidth - XCTAssertEqual(a.count, sample.count + 1) - XCTAssertEqual(a[0], 0) - XCTAssertEqual(a.extract(1 ... sample.count + 1), sample) - - a = sample - a <<= 100 * Word.bitWidth - XCTAssertEqual(a.count, sample.count + 100) - XCTAssertEqual(a.extract(0 ..< 100), 0) - XCTAssertEqual(a.extract(100 ... sample.count + 100), sample) - - a = sample - a <<= 100 * Word.bitWidth + 2 - XCTAssertEqual(a.count, sample.count + 100) - XCTAssertEqual(a.extract(0 ..< 100), 0) - XCTAssertEqual(a.extract(100 ... sample.count + 100), sample << 2) - - a = sample - a <<= Word.bitWidth - 1 - XCTAssertEqual(a.count, sample.count + 1) - XCTAssertEqual(a, BigUInt(words: [0] + sample.words) / 2) - - - a = sample - a <<= -4 - XCTAssertEqual(a, sample / 16) - - XCTAssertEqual(sample << 0, sample) - XCTAssertEqual(sample << 1, 2 * sample) - XCTAssertEqual(sample << 2, 4 * sample) - XCTAssertEqual(sample << 4, 16 * sample) - XCTAssertEqual(sample << Word.bitWidth, BigUInt(words: [0 as Word] + sample.words)) - XCTAssertEqual(sample << (Word.bitWidth - 1), BigUInt(words: [0] + sample.words) / 2) - XCTAssertEqual(sample << (Word.bitWidth + 1), BigUInt(words: [0] + sample.words) * 2) - XCTAssertEqual(sample << (Word.bitWidth + 2), BigUInt(words: [0] + sample.words) * 4) - XCTAssertEqual(sample << (2 * Word.bitWidth), BigUInt(words: [0, 0] + sample.words)) - XCTAssertEqual(sample << (2 * Word.bitWidth + 2), BigUInt(words: [0, 0] + (4 * sample).words)) - - XCTAssertEqual(sample << -1, sample / 2) - XCTAssertEqual(sample << -4, sample / 16) - } - - func testRightShifts() { - let sample = BigUInt("123456789ABCDEF1234567891631832727633", radix: 16)! - - var a = sample - - a >>= BigUInt(0) - XCTAssertEqual(a, sample) - - a >>= 0 - XCTAssertEqual(a, sample) - - a = sample - a >>= 1 - XCTAssertEqual(a, sample / 2) - - a = sample - a >>= Word.bitWidth - XCTAssertEqual(a, sample.extract(1...)) - - a = sample - a >>= Word.bitWidth + 2 - XCTAssertEqual(a, sample.extract(1...) / 4) - - a = sample - a >>= sample.count * Word.bitWidth - XCTAssertEqual(a, 0) - - a = sample - a >>= 1000 - XCTAssertEqual(a, 0) - - a = sample - a >>= 100 * Word.bitWidth - XCTAssertEqual(a, 0) - - a = sample - a >>= 100 * BigUInt(Word.max) - XCTAssertEqual(a, 0) - - a = sample - a >>= -1 - XCTAssertEqual(a, sample * 2) - - a = sample - a >>= -4 - XCTAssertEqual(a, sample * 16) - - XCTAssertEqual(sample >> BigUInt(0), sample) - XCTAssertEqual(sample >> 0, sample) - XCTAssertEqual(sample >> 1, sample / 2) - XCTAssertEqual(sample >> 3, sample / 8) - XCTAssertEqual(sample >> Word.bitWidth, sample.extract(1 ..< sample.count)) - XCTAssertEqual(sample >> (Word.bitWidth + 2), sample.extract(1...) / 4) - XCTAssertEqual(sample >> (Word.bitWidth + 3), sample.extract(1...) / 8) - XCTAssertEqual(sample >> (sample.count * Word.bitWidth), 0) - XCTAssertEqual(sample >> (100 * Word.bitWidth), 0) - XCTAssertEqual(sample >> (100 * BigUInt(Word.max)), 0) - - XCTAssertEqual(sample >> -1, sample * 2) - XCTAssertEqual(sample >> -4, sample * 16) - } - - func testSquareRoot() { - let sample = BigUInt("123456789ABCDEF1234567891631832727633", radix: 16)! - - XCTAssertEqual(BigUInt(0).squareRoot(), 0) - XCTAssertEqual(BigUInt(256).squareRoot(), 16) - - func checkSqrt(_ value: BigUInt, file: StaticString = #file, line: UInt = #line) { - let root = value.squareRoot() - XCTAssertLessThanOrEqual(root * root, value, "\(value)", file: file, line: line) - XCTAssertGreaterThan((root + 1) * (root + 1), value, "\(value)", file: file, line: line) - } - for i in 0 ... 100 { - checkSqrt(BigUInt(i)) - checkSqrt(BigUInt(i) << 100) - } - checkSqrt(sample) - checkSqrt(sample * sample) - checkSqrt(sample * sample - 1) - checkSqrt(sample * sample + 1) - } - - func testGCD() { - XCTAssertEqual(BigUInt(0).greatestCommonDivisor(with: 2982891), 2982891) - XCTAssertEqual(BigUInt(2982891).greatestCommonDivisor(with: 0), 2982891) - XCTAssertEqual(BigUInt(0).greatestCommonDivisor(with: 0), 0) - - XCTAssertEqual(BigUInt(4).greatestCommonDivisor(with: 6), 2) - XCTAssertEqual(BigUInt(15).greatestCommonDivisor(with: 10), 5) - XCTAssertEqual(BigUInt(8 * 3 * 25 * 7).greatestCommonDivisor(with: 2 * 9 * 5 * 49), 2 * 3 * 5 * 7) - - var fibo: [BigUInt] = [0, 1] - for i in 0...10000 { - fibo.append(fibo[i] + fibo[i + 1]) - } - - XCTAssertEqual(BigUInt(fibo[100]).greatestCommonDivisor(with: fibo[101]), 1) - XCTAssertEqual(BigUInt(fibo[1000]).greatestCommonDivisor(with: fibo[1001]), 1) - XCTAssertEqual(BigUInt(fibo[10000]).greatestCommonDivisor(with: fibo[10001]), 1) - - XCTAssertEqual(BigUInt(3 * 5 * 7 * 9).greatestCommonDivisor(with: 5 * 7 * 7), 5 * 7) - XCTAssertEqual(BigUInt(fibo[4]).greatestCommonDivisor(with: fibo[2]), fibo[2]) - XCTAssertEqual(BigUInt(fibo[3 * 5 * 7 * 9]).greatestCommonDivisor(with: fibo[5 * 7 * 7 * 9]), fibo[5 * 7 * 9]) - XCTAssertEqual(BigUInt(fibo[7 * 17 * 83]).greatestCommonDivisor(with: fibo[6 * 17 * 83]), fibo[17 * 83]) - } - - func testInverse() { - XCTAssertNil(BigUInt(4).inverse(2)) - XCTAssertNil(BigUInt(4).inverse(8)) - XCTAssertNil(BigUInt(12).inverse(15)) - XCTAssertEqual(BigUInt(13).inverse(15), 7) - - XCTAssertEqual(BigUInt(251).inverse(1023), 269) - XCTAssertNil(BigUInt(252).inverse(1023)) - XCTAssertEqual(BigUInt(2).inverse(1023), 512) - } - - - func testStrongProbablePrimeTest() { - let primes: [BigUInt.Word] = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 79, 83, 89, 97] - let pseudoPrimes: [BigUInt] = [ - /* 2 */ 2_047, - /* 3 */ 1_373_653, - /* 5 */ 25_326_001, - /* 7 */ 3_215_031_751, - /* 11 */ 2_152_302_898_747, - /* 13 */ 3_474_749_660_383, - /* 17 */ 341_550_071_728_321, - /* 19 */ 341_550_071_728_321, - /* 23 */ 3_825_123_056_546_413_051, - /* 29 */ 3_825_123_056_546_413_051, - /* 31 */ 3_825_123_056_546_413_051, - /* 37 */ "318665857834031151167461", - /* 41 */ "3317044064679887385961981", - ] - for i in 0.. = [2, 3, 5, 7, 13, 17, 19, 31, 61, 89, 107, 127, 521] - for exponent in 2..<200 { - let m = BigUInt(1) << exponent - 1 - XCTAssertEqual(m.isPrime(), mp.contains(exponent), "\(exponent)") - } - } - - func testConversionToString() { - let sample = BigUInt("123456789ABCDEFEDCBA98765432123456789ABCDEF", radix: 16)! - // Radix = 10 - XCTAssertEqual(String(BigUInt()), "0") - XCTAssertEqual(String(BigUInt(1)), "1") - XCTAssertEqual(String(BigUInt(100)), "100") - XCTAssertEqual(String(BigUInt(12345)), "12345") - XCTAssertEqual(String(BigUInt(123456789)), "123456789") - XCTAssertEqual(String(sample), "425693205796080237694414176550132631862392541400559") - - // Radix = 16 - XCTAssertEqual(String(BigUInt(0x1001), radix: 16), "1001") - XCTAssertEqual(String(BigUInt(0x0102030405060708), radix: 16), "102030405060708") - XCTAssertEqual(String(sample, radix: 16), "123456789abcdefedcba98765432123456789abcdef") - XCTAssertEqual(String(sample, radix: 16, uppercase: true), "123456789ABCDEFEDCBA98765432123456789ABCDEF") - - // Radix = 2 - XCTAssertEqual(String(BigUInt(12), radix: 2), "1100") - XCTAssertEqual(String(BigUInt(123), radix: 2), "1111011") - XCTAssertEqual(String(BigUInt(1234), radix: 2), "10011010010") - XCTAssertEqual(String(sample, radix: 2), "1001000110100010101100111100010011010101111001101111011111110110111001011101010011000011101100101010000110010000100100011010001010110011110001001101010111100110111101111") - - // Radix = 31 - XCTAssertEqual(String(BigUInt(30), radix: 31), "u") - XCTAssertEqual(String(BigUInt(31), radix: 31), "10") - XCTAssertEqual(String(BigUInt("10000000000000000", radix: 16)!, radix: 31), "nd075ib45k86g") - XCTAssertEqual(String(BigUInt("2908B5129F59DB6A41", radix: 16)!, radix: 31), "100000000000000") - XCTAssertEqual(String(sample, radix: 31), "ptf96helfaqi7ogc3jbonmccrhmnc2b61s") - - let quickLook = BigUInt(513).playgroundDescription as? String - if quickLook == "513 (10 bits)" { - } else { - XCTFail("Unexpected playground QuickLook representation: \(quickLook ?? "nil")") - } - } - - func testConversionFromString() { - let sample = "123456789ABCDEFEDCBA98765432123456789ABCDEF" - - XCTAssertEqual(BigUInt("1"), 1) - XCTAssertEqual(BigUInt("123456789ABCDEF", radix: 16)!, 0x123456789ABCDEF) - XCTAssertEqual(BigUInt("1000000000000000000000"), BigUInt("3635C9ADC5DEA00000", radix: 16)) - XCTAssertEqual(BigUInt("10000000000000000", radix: 16), BigUInt("18446744073709551616")) - XCTAssertEqual(BigUInt(sample, radix: 16)!, BigUInt("425693205796080237694414176550132631862392541400559")) - - // We have to call BigUInt.init here because we don't want Literal initialization via coercion (SE-0213) - XCTAssertNil(BigUInt.init("Not a number")) - XCTAssertNil(BigUInt.init("X")) - XCTAssertNil(BigUInt.init("12349A")) - XCTAssertNil(BigUInt.init("000000000000000000000000A000")) - XCTAssertNil(BigUInt.init("00A0000000000000000000000000")) - XCTAssertNil(BigUInt.init("00 0000000000000000000000000")) - XCTAssertNil(BigUInt.init("\u{4e00}\u{4e03}")) // Chinese numerals "1", "7" - - XCTAssertEqual(BigUInt("u", radix: 31)!, 30) - XCTAssertEqual(BigUInt("10", radix: 31)!, 31) - XCTAssertEqual(BigUInt("100000000000000", radix: 31)!, BigUInt("2908B5129F59DB6A41", radix: 16)!) - XCTAssertEqual(BigUInt("nd075ib45k86g", radix: 31)!, BigUInt("10000000000000000", radix: 16)!) - XCTAssertEqual(BigUInt("ptf96helfaqi7ogc3jbonmccrhmnc2b61s", radix: 31)!, BigUInt(sample, radix: 16)!) - - XCTAssertNotNil(BigUInt(sample.repeated(100), radix: 16)) - } - - func testRandomIntegerWithMaximumWidth() { - XCTAssertEqual(BigUInt.randomInteger(withMaximumWidth: 0), 0) - - let randomByte = BigUInt.randomInteger(withMaximumWidth: 8) - XCTAssertLessThan(randomByte, 256) - - for _ in 0 ..< 100 { - XCTAssertLessThanOrEqual(BigUInt.randomInteger(withMaximumWidth: 1024).bitWidth, 1024) - } - - // Verify that all widths <= maximum are produced (with a tiny maximum) - var widths: Set = [0, 1, 2, 3] - var i = 0 - while !widths.isEmpty { - let random = BigUInt.randomInteger(withMaximumWidth: 3) - XCTAssertLessThanOrEqual(random.bitWidth, 3) - widths.remove(random.bitWidth) - i += 1 - if i > 4096 { - XCTFail("randomIntegerWithMaximumWidth doesn't seem random") - break - } - } - - // Verify that all bits are sometimes zero, sometimes one. - var oneBits = Set(0..<1024) - var zeroBits = Set(0..<1024) - while !oneBits.isEmpty || !zeroBits.isEmpty { - var random = BigUInt.randomInteger(withMaximumWidth: 1024) - for i in 0..<1024 { - if random[0] & 1 == 1 { oneBits.remove(i) } - else { zeroBits.remove(i) } - random >>= 1 - } - } - } - - func testRandomIntegerWithExactWidth() { - XCTAssertEqual(BigUInt.randomInteger(withExactWidth: 0), 0) - XCTAssertEqual(BigUInt.randomInteger(withExactWidth: 1), 1) - - for _ in 0 ..< 1024 { - let randomByte = BigUInt.randomInteger(withExactWidth: 8) - XCTAssertEqual(randomByte.bitWidth, 8) - XCTAssertLessThan(randomByte, 256) - XCTAssertGreaterThanOrEqual(randomByte, 128) - } - - for _ in 0 ..< 100 { - XCTAssertEqual(BigUInt.randomInteger(withExactWidth: 1024).bitWidth, 1024) - } - - // Verify that all bits except the top are sometimes zero, sometimes one. - var oneBits = Set(0..<1023) - var zeroBits = Set(0..<1023) - while !oneBits.isEmpty || !zeroBits.isEmpty { - var random = BigUInt.randomInteger(withExactWidth: 1024) - for i in 0..<1023 { - if random[0] & 1 == 1 { oneBits.remove(i) } - else { zeroBits.remove(i) } - random >>= 1 - } - } - } - - func testRandomIntegerLessThan() { - // Verify that all bits in random integers generated by `randomIntegerLessThan` are sometimes zero, sometimes one. - // - // The limit starts with "11" so that generated random integers may easily begin with all combos. - // Also, 25% of the time the initial random int will be rejected as higher than the - // limit -- this helps stabilize code coverage. - let limit = BigUInt(3) << 1024 - var oneBits = Set(0..(0..>= 1 - } - } - XCTAssertEqual(oneBits, []) - XCTAssertEqual(zeroBits, []) - } - - func testRandomFunctionsUseProvidedGenerator() { - // Here I verify that each of the randomInteger functions uses the provided RNG, and not SystemRandomNumberGenerator. - // This is important because all but BigUInt.randomInteger(withMaximumWidth:using:) are built on that base function, and it is easy to forget to pass along the provided generator and get a default SystemRandomNumberGenerator instead. - - // Since SystemRandomNumberGenerator is seeded randomly, repeated uses should give varying results. - // So here I pass the same deterministic RNG repeatedly and verify that I get the same result each time. - - struct CountingRNG: RandomNumberGenerator { - var i: UInt64 = 12345 - mutating func next() -> UInt64 { - i += 1 - return i - } - } - - func gen(_ body: (inout CountingRNG) -> BigUInt) -> BigUInt { - var rng = CountingRNG() - return body(&rng) - } - - func check(_ body: (inout CountingRNG) -> BigUInt) { - let expected = gen(body) - for _ in 0 ..< 100 { - let actual = gen(body) - XCTAssertEqual(expected, actual) - } - } - - check { BigUInt.randomInteger(withMaximumWidth: 200, using: &$0) } - check { BigUInt.randomInteger(withExactWidth: 200, using: &$0) } - let limit = BigUInt(UInt64.max) * BigUInt(UInt64.max) * BigUInt(UInt64.max) - check { BigUInt.randomInteger(lessThan: limit, using: &$0) } - } - - // - // you have to manually register linux tests here :-( - // - static var allTests = [ - ("testInit_WordBased", testInit_WordBased), - ("testInit_BinaryInteger", testInit_BinaryInteger), - ("testInit_FloatingPoint", testInit_FloatingPoint), - ("testInit_Buffer", testInit_Buffer), - ("testConversionToFloatingPoint", testConversionToFloatingPoint), - ("testInit_Misc", testInit_Misc), - ("testEnsureArray", testEnsureArray), - // ("testCapacity", testCapacity), - // ("testReserveCapacity", testReserveCapacity), - // ("testLoad", testLoad), - ("testInitFromLiterals", testInitFromLiterals), - ("testSubscriptingGetter", testSubscriptingGetter), - ("testSubscriptingSetter", testSubscriptingSetter), - ("testSlice", testSlice), - ("testSigns", testSigns), - ("testBits", testBits), - ("testStrideableRequirements", testStrideableRequirements), - ("testRightShift_ByWord", testRightShift_ByWord), - ("testLeftShift_ByWord", testLeftShift_ByWord), - ("testSplit", testSplit), - ("testLowHigh", testLowHigh), - ("testComparison", testComparison), - ("testHashing", testHashing), - ("testConversionFromBytes", testConversionFromBytes), - ("testConversionToData", testConversionToData), - ("testCodable", testCodable), - ("testAddition", testAddition), - ("testShiftedAddition", testShiftedAddition), - ("testSubtraction", testSubtraction), - ("testMultiplyByWord", testMultiplyByWord), - ("testMultiplication", testMultiplication), - ("testDivision", testDivision), - ("testFactorial", testFactorial), - ("testExponentiation", testExponentiation), - ("testModularExponentiation", testModularExponentiation), - ("testBitWidth", testBitWidth), - ("testBitwise", testBitwise), - ("testLeftShifts", testLeftShifts), - ("testRightShifts", testRightShifts), - ("testSquareRoot", testSquareRoot), - ("testGCD", testGCD), - ("testInverse", testInverse), - ("testStrongProbablePrimeTest", testStrongProbablePrimeTest), - ("testIsPrime", testIsPrime), - ("testConversionToString", testConversionToString), - ("testConversionFromString", testConversionFromString), - ("testRandomIntegerWithMaximumWidth", testRandomIntegerWithMaximumWidth), - ("testRandomIntegerWithExactWidth", testRandomIntegerWithExactWidth), - ("testRandomIntegerLessThan", testRandomIntegerLessThan), - ("testRandomFunctionsUseProvidedGenerator", testRandomFunctionsUseProvidedGenerator), - ] -} diff --git a/Carthage/Checkouts/BigInt/Tests/BigIntTests/Info.plist b/Carthage/Checkouts/BigInt/Tests/BigIntTests/Info.plist deleted file mode 100644 index ba72822e8..000000000 --- a/Carthage/Checkouts/BigInt/Tests/BigIntTests/Info.plist +++ /dev/null @@ -1,24 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - BNDL - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleVersion - 1 - - diff --git a/Carthage/Checkouts/BigInt/Tests/BigIntTests/ProfileTests.swift b/Carthage/Checkouts/BigInt/Tests/BigIntTests/ProfileTests.swift deleted file mode 100644 index 12aa0aa6d..000000000 --- a/Carthage/Checkouts/BigInt/Tests/BigIntTests/ProfileTests.swift +++ /dev/null @@ -1,228 +0,0 @@ -// -// ProfileTests.swift -// BigInt -// -// Created by Károly Lőrentey on 2015-12-31. -// Copyright © 2016-2017 Károly Lőrentey. -// - -import XCTest -import BigInt - -#if Profile - -func factorial(_ n: Int) -> BigUInt { - var fact = BigUInt(1) - for i in BigUInt.Word(1) ... BigUInt.Word(n) { - fact.multiply(byWord: i) - } - return fact -} - -class ProfileTests: XCTestCase { - typealias Word = BigUInt.Word - - func measure_(autostart: Bool = true, block: @escaping ()->Void) { - var round = 0 - self.measureMetrics(type(of: self).defaultPerformanceMetrics, automaticallyStartMeasuring: autostart) { - print("Round \(round) started") - block() - round += 1 - } - } - - func testFibonacciAddition() { - var n1 = BigUInt(1) - var n2 = BigUInt(1) - self.measure { - n1 = BigUInt(1) - n2 = BigUInt(1) - for i in 0..<200000 { - if i & 1 == 0 { - n1 += n2 - } - else { - n2 += n1 - } - } - } - noop(n1) - noop(n2) - } - - func checkFactorial(fact: BigUInt, n: Int, file: StaticString = #file, line: UInt = #line) { - var remaining = fact - for i in 1...n { - let (div, mod) = remaining.quotientAndRemainder(dividingBy: BigUInt(i)) - XCTAssertEqual(mod, 0, "for divisor = \(i)", file: file, line: line) - remaining = div - } - XCTAssertEqual(remaining, 1, file: file, line: line) - } - - func testDivisionOfFactorial() { - let n = 32767 - let fact = factorial(n) - self.measure { - checkFactorial(fact: fact, n: n) - } - } - - func testPrintingFactorial() { - let n = 32767 - let fact = factorial(n) - var string: String = "" - self.measure { - string = String(fact, radix: 10) - } - XCTAssertEqual(BigUInt(string, radix: 10), fact) - } - - func testReadingFactorial() { - let n = 32767 - let fact = factorial(n) - let string = String(fact, radix: 10) - print(string) - self.measure { - XCTAssertEqual(BigUInt(string, radix: 10), fact) - } - } - - func testFactorial() { - var fact = BigUInt() - let n = 32767 - self.measure { - fact = factorial(n) - } - checkFactorial(fact: fact, n: n) - } - - func testBalancedFactorial() { - func balancedFactorial(level: Int, offset: Int = 0) -> BigUInt { - if level == 0 { - return BigUInt(offset == 0 ? 1 : offset) - } - let a = balancedFactorial(level: level - 1, offset: 2 * offset) - let b = balancedFactorial(level: level - 1, offset: 2 * offset + 1) - return a * b - } - - let power = 15 - - var fact = BigUInt() - self.measure { - fact = balancedFactorial(level: power) - } - checkFactorial(fact: fact, n: ((1 as Int) << power) - 1) - } - - func testDivision() { - var divisors: [BigUInt] = [] - func balancedFactorial(level: Int, offset: Int = 0) -> BigUInt { - if level == 0 { - return BigUInt(offset == 0 ? 1 : offset) - } - let a = balancedFactorial(level: level - 1, offset: 2 * offset) - let b = balancedFactorial(level: level - 1, offset: 2 * offset + 1) - let p = a * b - if level >= 10 { divisors.append(p) } - return p - } - - let power = 14 - - let fact = balancedFactorial(level: power) - print("Performing \(divisors.count) divisions with digit counts (\(fact.words.count) / (\(divisors[0].words.count)...\(divisors[divisors.count - 1].words.count))") - var divs: [BigUInt] = [] - var mods: [BigUInt] = [] - divs.reserveCapacity(divisors.count) - mods.reserveCapacity(divisors.count) - self.measure_(autostart: false) { - divs.removeAll() - mods.removeAll() - self.startMeasuring() - for divisor in divisors { - let (div, mod) = fact.quotientAndRemainder(dividingBy: divisor) - divs.append(div) - mods.append(mod) - } - self.stopMeasuring() - } - for i in 0.. [BigUInt] { - var rnd = PseudoRandomNumbers(seed: seed) - return (0 ..< count).map { _ in BigUInt(words: (0 ..< words).map { _ in rnd.next()! }) } - } - - func testSquareRoot() { - let numbers = randomBigUInts(1000, seed: 42, withMaxWords: 60) - var roots: [BigUInt] = [] - self.measure { - roots.removeAll() - for number in numbers { - let root = number.squareRoot() - roots.append(root) - } - } - - for i in 0.. = [2, 3, 5, 7, 13, 17, 19, 31, 61, 89, 107, 127, 521, 607, 1279, 2203, 2281] - for exp in 1...1000 { - let mersenne = BigUInt(1) << exp - 1 - XCTAssertEqual(mersenne.isPrime(), exponents.contains(exp), "\(exp) smells fishy") - } - // Seems legit. You win this round, evil magmaticians - } - } -} -#endif diff --git a/Carthage/Checkouts/BigInt/Tests/BigIntTests/Tools.swift b/Carthage/Checkouts/BigInt/Tests/BigIntTests/Tools.swift deleted file mode 100644 index 3c2484184..000000000 --- a/Carthage/Checkouts/BigInt/Tests/BigIntTests/Tools.swift +++ /dev/null @@ -1,48 +0,0 @@ -// -// Tools.swift -// BigInt -// -// Created by Károly Lőrentey on 2017-7-23. -// Copyright © 2017 Károly Lőrentey. All rights reserved. -// - -import BigInt - -@inline(never) -func noop(_ value: T) { - _ = value -} - -// A basic low-quality random number generator. -struct PseudoRandomNumbers: Sequence, IteratorProtocol { - typealias Element = BigUInt.Word - var last: Element - - init(seed: Element) { - self.last = seed - } - - mutating func next() -> Element? { - // Constants are from Knuth's MMIX and Numerical Recipes, respectively - let a: Element = (Element.bitWidth == 8 ? 6364136223846793005 : 1664525) - let c: Element = (Element.bitWidth == 8 ? 1442695040888963407 : 1013904223) - last = a &* last &+ c - return last - } -} - -func convertWords(_ wideWords: S) -> [UInt] where S.Element == UInt64 { - return wideWords.flatMap { $0.words } -} - -extension String { - func repeated(_ count: Int) -> String { - var result = "" - for _ in 0 ..< count { - result += self - } - return result - } -} - - diff --git a/Carthage/Checkouts/BigInt/Tests/BigIntTests/WordTests.swift b/Carthage/Checkouts/BigInt/Tests/BigIntTests/WordTests.swift deleted file mode 100644 index 53204b3fc..000000000 --- a/Carthage/Checkouts/BigInt/Tests/BigIntTests/WordTests.swift +++ /dev/null @@ -1,137 +0,0 @@ -// -// WordTests.swift -// BigInt -// -// Created by Károly Lőrentey on 2017-7-26. -// Copyright © 2017 Károly Lőrentey. All rights reserved. -// - -import XCTest -@testable import BigInt - -struct TestDivision where Word.Magnitude == Word { - static func testDivision(_ u: (high: Word, low: Word.Magnitude), _ v: Word) { - let (div, mod) = v.fastDividingFullWidth(u) - var (ph, pl) = div.multipliedFullWidth(by: v) - let (s, o) = pl.addingReportingOverflow(mod) - pl = s - if o { ph += Word(1) } - - if mod >= v { - XCTFail("For u = \(u), v = \(v): u mod v = \(mod), which is greater than v") - } - - func message() -> String { - let uhs = String(u.high, radix: 16) - let uls = String(u.low, radix: 16) - let vs = String(v, radix: 16) - let divs = String(div, radix: 16) - let mods = String(mod, radix: 16) - let phs = String(ph, radix: 16) - let pls = String(pl, radix: 16) - return "(\(uhs),\(uls)) / \(vs) = (\(divs), \(mods)), but div * v + mod = (\(phs),\(pls))" - } - XCTAssertEqual(ph, u.high, message()) - XCTAssertEqual(pl, u.low, message()) - } - - static func test() { - testDivision((0, 0), 2) - testDivision((0, 1), 2) - testDivision((1, 0), 2) - testDivision((8, 0), 136) - testDivision((128, 0), 136) - testDivision((2, 0), 35) - testDivision((7, 12), 19) - } -} - -class WordTests: XCTestCase { - func testFullDivide() { - TestDivision.test() - TestDivision.test() - TestDivision.test() - TestDivision.test() - TestDivision.test() - - #if false - typealias Word = UInt8 - for v in 1 ... Word.max { - for u1 in 0 ..< v { - for u0 in 0 ..< Word.max { - TestDivision.testDivision((u1, u0), v) - } - } - } - #endif - } - - func testConversion() { - enum Direction { - case unitsToWords - case wordsToUnits - case both - } - func test - (direction: Direction = .both, - words: [Word], of wtype: Word.Type = Word.self, - units: [Unit], of utype: Unit.Type = Unit.self, - file: StaticString = #file, line: UInt = #line) { - switch direction { - case .wordsToUnits, .both: - let actualUnits = [Unit](Units(of: Unit.self, words)) - XCTAssertEqual(actualUnits, units, "words -> units", file: file, line: line) - default: - break - } - switch direction { - case .unitsToWords, .both: - var it = units.makeIterator() - let actualWords = [Word](count: units.count, generator: { () -> Unit? in it.next() }) - XCTAssertEqual(actualWords, words, "units -> words", file: file, line: line) - default: - break - } - } - - - test(words: [], of: UInt8.self, - units: [], of: UInt8.self) - test(words: [0x01], of: UInt8.self, - units: [0x01], of: UInt8.self) - test(words: [0x01, 0x02], of: UInt8.self, - units: [0x02, 0x01], of: UInt8.self) - - test(words: [], of: UInt8.self, - units: [], of: UInt16.self) - test(direction: .unitsToWords, - words: [0x01, 0x00], of: UInt8.self, - units: [0x0001], of: UInt16.self) - test(direction: .wordsToUnits, - words: [0x01], of: UInt8.self, - units: [0x0001], of: UInt16.self) - test(words: [0x01, 0x02], of: UInt8.self, - units: [0x0201], of: UInt16.self) - test(direction: .wordsToUnits, - words: [0x01, 0x02, 0x03], of: UInt8.self, - units: [0x0003, 0x0201], of: UInt16.self) - test(direction: .unitsToWords, - words: [0x01, 0x02, 0x03, 0x00], of: UInt8.self, - units: [0x0003, 0x0201], of: UInt16.self) - - test(words: [], of: UInt16.self, - units: [], of: UInt8.self) - test(words: [0x1234], of: UInt16.self, - units: [0x12, 0x34], of: UInt8.self) - test(words: [0x5678, 0x1234], of: UInt16.self, - units: [0x12, 0x34, 0x56, 0x78], of: UInt8.self) - test(direction: .unitsToWords, - words: [0x789A, 0x3456, 0x12], of: UInt16.self, - units: [0x12, 0x34, 0x56, 0x78, 0x9A], of: UInt8.self) - test(direction: .wordsToUnits, - words: [0x789A, 0x3456, 0x12], of: UInt16.self, - units: [0x00, 0x12, 0x34, 0x56, 0x78, 0x9A], of: UInt8.self) - } -} - - diff --git a/Carthage/Checkouts/BigInt/docs/Extensions.html b/Carthage/Checkouts/BigInt/docs/Extensions.html deleted file mode 100644 index b9203ad28..000000000 --- a/Carthage/Checkouts/BigInt/docs/Extensions.html +++ /dev/null @@ -1,176 +0,0 @@ - - - - Extensions Reference - - - - - - - - - - - - - - - -
-

- - BigInt Docs - - (92% documented) -

- -

-

- -
-

- -

- - - View on GitHub - -

- -

- - - Install in Dash - -

-
- - - -
- -
- -
-
-

Extensions

-

The following extensions are available globally.

- -
-
- -
-
-
-
    -
  • -
    - - - - BinaryFloatingPoint - -
    -
    -
    -
    -
    -
    - - See more -
    -
    -

    Declaration

    -
    -

    Swift

    -
    protocol BinaryFloatingPoint : FloatingPoint, ExpressibleByFloatLiteral
    - -
    -
    -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - String - -
    -
    -
    -
    -
    -
    - - See more -
    -
    -

    Declaration

    -
    -

    Swift

    -
    struct String
    - -
    -
    -
    -
    -
  • -
-
-
-
- -
-
- - - - diff --git a/Carthage/Checkouts/BigInt/docs/Extensions/BinaryFloatingPoint.html b/Carthage/Checkouts/BigInt/docs/Extensions/BinaryFloatingPoint.html deleted file mode 100644 index 648ecee7b..000000000 --- a/Carthage/Checkouts/BigInt/docs/Extensions/BinaryFloatingPoint.html +++ /dev/null @@ -1,184 +0,0 @@ - - - - BinaryFloatingPoint Extension Reference - - - - - - - - - - - - - - - - -
-

- - BigInt Docs - - (92% documented) -

- -

-

- -
-

- -

- - - View on GitHub - -

- -

- - - Install in Dash - -

-
- - - -
- -
- -
-
-

BinaryFloatingPoint

-
-
-
protocol BinaryFloatingPoint : FloatingPoint, ExpressibleByFloatLiteral
- -
-
- -
-
- -
-
-
-
    -
  • -
    - - - - init(_:) - -
    -
    -
    -
    -
    -
    -

    Undocumented

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    protocol BinaryFloatingPoint : FloatingPoint, ExpressibleByFloatLiteral
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - init(_:) - -
    -
    -
    -
    -
    -
    -

    Undocumented

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    protocol BinaryFloatingPoint : FloatingPoint, ExpressibleByFloatLiteral
    - -
    -
    - -
    -
    -
  • -
-
-
-
- -
-
- - - - diff --git a/Carthage/Checkouts/BigInt/docs/Extensions/String.html b/Carthage/Checkouts/BigInt/docs/Extensions/String.html deleted file mode 100644 index 3b61515d6..000000000 --- a/Carthage/Checkouts/BigInt/docs/Extensions/String.html +++ /dev/null @@ -1,245 +0,0 @@ - - - - String Extension Reference - - - - - - - - - - - - - - - - -
-

- - BigInt Docs - - (92% documented) -

- -

-

- -
-

- -

- - - View on GitHub - -

- -

- - - Install in Dash - -

-
- - - -
- -
- -
-
-

String

-
-
-
struct String
- -
-
- -
-
- -
-
-
-
    -
  • -
    - - - - init(_:) - -
    -
    -
    -
    -
    -
    -

    Initialize a new string with the base-10 representation of an unsigned big integer.

    -
    -

    Complexity

    - O(v.count^2) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init(_ v: BigUInt)
    - -
    -
    - -
    -
    -
  • -
  • - -
    -
    -
    -
    -
    -

    Initialize a new string representing an unsigned big integer in the given radix (base).

    - -

    Numerals greater than 9 are represented as letters from the English alphabet, -starting with a if uppercase is false or A otherwise.

    -
    -

    Requires

    - radix > 1 && radix <= 36 - -
    -
    -

    Complexity

    - O(count) when radix is a power of two; otherwise O(count^2). - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init(_ v: BigUInt, radix: Int, uppercase: Bool = false)
    - -
    -
    - -
    -
    -
  • -
  • - -
    -
    -
    -
    -
    -

    Initialize a new string representing a signed big integer in the given radix (base).

    - -

    Numerals greater than 9 are represented as letters from the English alphabet, -starting with a if uppercase is false or A otherwise.

    -
    -

    Requires

    - radix > 1 && radix <= 36 - -
    -
    -

    Complexity

    - O(count) when radix is a power of two; otherwise O(count^2). - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init(_ value: BigInt, radix: Int = 10, uppercase: Bool = false)
    - -
    -
    - -
    -
    -
  • -
-
-
-
- -
-
- - - - diff --git a/Carthage/Checkouts/BigInt/docs/Structs.html b/Carthage/Checkouts/BigInt/docs/Structs.html deleted file mode 100644 index 366be84d2..000000000 --- a/Carthage/Checkouts/BigInt/docs/Structs.html +++ /dev/null @@ -1,211 +0,0 @@ - - - - Structures Reference - - - - - - - - - - - - - - - -
-

- - BigInt Docs - - (92% documented) -

- -

-

- -
-

- -

- - - View on GitHub - -

- -

- - - Install in Dash - -

-
- - - -
- -
- -
-
-

Structures

-

The following structures are available globally.

- -
-
- -
-
-
-
    -
  • -
    - - - - BigUInt - -
    -
    -
    -
    -
    -
    -

    An arbitary precision unsigned integer type, also known as a big integer.

    - -

    Operations on big integers never overflow, but they may take a long time to execute. -The amount of memory (and address space) available is the only constraint to the magnitude of these numbers.

    - -

    This particular big integer type uses base-2^64 digits to represent integers; you can think of it as a wrapper -around Array<UInt64>. (In fact, BigUInt only uses an array if there are more than two digits.)

    - - See more -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public struct BigUInt: UnsignedInteger
    - -
    -
    - -
    -
    -
  • -
-
-
-
- - - -

BigInt

-
-
-
    -
  • -
    - - - - BigInt - -
    -
    -
    -
    -
    -
    -

    An arbitary precision signed integer type, also known as a big integer.

    - -

    Operations on big integers never overflow, but they might take a long time to execute. -The amount of memory (and address space) available is the only constraint to the magnitude of these numbers.

    - -

    This particular big integer type uses base-2^64 digits to represent integers.

    - -

    BigInt is essentially a tiny wrapper that extends BigUInt with a sign bit and provides signed integer -operations. Both the underlying absolute value and the negative/positive flag are available as read-write -properties.

    - -

    Not all algorithms of BigUInt are available for BigInt values; for example, there is no square root or -primality test for signed integers. When you need to call one of these, just extract the absolute value:

    -
    BigInt(255).abs.isPrime()   // Returns false
    -
    - - See more -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public struct BigInt: SignedInteger
    - -
    -
    - -
    -
    -
  • -
-
-
-
- -
-
- - - - diff --git a/Carthage/Checkouts/BigInt/docs/Structs/BigInt.html b/Carthage/Checkouts/BigInt/docs/Structs/BigInt.html deleted file mode 100644 index 7bc104afd..000000000 --- a/Carthage/Checkouts/BigInt/docs/Structs/BigInt.html +++ /dev/null @@ -1,2427 +0,0 @@ - - - - BigInt Structure Reference - - - - - - - - - - - - - - - - -
-

- - BigInt Docs - - (92% documented) -

- -

-

- -
-

- -

- - - View on GitHub - -

- -

- - - Install in Dash - -

-
- - - -
- -
- -
-
-

BigInt

-
-
-
public struct BigInt: SignedInteger
- -
-
-

An arbitary precision signed integer type, also known as a big integer.

- -

Operations on big integers never overflow, but they might take a long time to execute. -The amount of memory (and address space) available is the only constraint to the magnitude of these numbers.

- -

This particular big integer type uses base-2^64 digits to represent integers.

- -

BigInt is essentially a tiny wrapper that extends BigUInt with a sign bit and provides signed integer -operations. Both the underlying absolute value and the negative/positive flag are available as read-write -properties.

- -

Not all algorithms of BigUInt are available for BigInt values; for example, there is no square root or -primality test for signed integers. When you need to call one of these, just extract the absolute value:

-
BigInt(255).abs.isPrime()   // Returns false
-
- -
-
- -
-
-
-
    -
  • -
    - - - - Sign - -
    -
    -
    -
    -
    -
    -

    Undocumented

    - - See more -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public struct BigInt: SignedInteger
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - Word - -
    -
    -
    -
    -
    -
    -

    The type representing a digit in BigInt‘s underlying number system.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public typealias Word = BigUInt.Word
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - isSigned - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static var isSigned: Bool
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - magnitude - -
    -
    -
    -
    -
    -
    -

    The absolute value of this integer.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var magnitude: BigUInt
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - sign - -
    -
    -
    -
    -
    -
    -

    True iff the value of this integer is negative.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var sign: Sign
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - init(sign:magnitude:) - -
    -
    -
    -
    -
    -
    -

    Initializes a new big integer with the provided absolute number and sign flag.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init(sign: Sign, magnitude: BigUInt)
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - isZero - -
    -
    -
    -
    -
    -
    -

    Return true iff this integer is zero.

    -
    -

    Complexity

    - O(1) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var isZero: Bool
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - signum() - -
    -
    -
    -
    -
    -
    -

    Returns -1 if this value is negative and 1 if it’s positive; otherwise, 0.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func signum() -> BigInt
    - -
    -
    -
    -

    Return Value

    -

    The sign of this number, expressed as an integer of the same type.

    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - ~(_:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static prefix func ~(x: BigInt) -> BigInt
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - &(_:_:) - -
    -
    -
    -
    -
    -
    -

    Undocumented

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public struct BigInt: SignedInteger
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - |(_:_:) - -
    -
    -
    -
    -
    -
    -

    Undocumented

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public struct BigInt: SignedInteger
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - ^(_:_:) - -
    -
    -
    -
    -
    -
    -

    Undocumented

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public struct BigInt: SignedInteger
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - &=(_:_:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func &=(lhs: inout BigInt, rhs: BigInt)
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - |=(_:_:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func |=(lhs: inout BigInt, rhs: BigInt)
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - ^=(_:_:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func ^=(lhs: inout BigInt, rhs: BigInt)
    - -
    -
    - -
    -
    -
  • -
-
-
- -
    -
  • - -
    -
    -
    -
    -
    -

    Returns true iff this integer passes the strong probable prime test for the specified base.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func isStrongProbablePrime(_ base: BigInt) -> Bool
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - isPrime(rounds:) - -
    -
    -
    -
    -
    -
    -

    Returns true if this integer is probably prime. Returns false if this integer is definitely not prime.

    - -

    This function performs a probabilistic Miller-Rabin Primality Test, consisting of rounds iterations, -each calculating the strong probable prime test for a random base. The number of rounds is 10 by default, -but you may specify your own choice.

    - -

    To speed things up, the function checks if self is divisible by the first few prime numbers before -diving into (slower) Miller-Rabin testing.

    - -

    Also, when self is less than 82 bits wide, isPrime does a deterministic test that is guaranteed to -return a correct result.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func isPrime(rounds: Int = 10) -> Bool
    - -
    -
    - -
    -
    -
  • -
-
-
- -
-
-
    -
  • -
    - - - - Words - -
    -
    -
    -
    -
    -
    - - See more -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public struct Words: RandomAccessCollection
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - words - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var words: Words
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - init(words:) - -
    -
    -
    -
    -
    -
    -

    Undocumented

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public struct BigInt: SignedInteger
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - appendHashes(to:) - -
    -
    -
    -
    -
    -
    -

    Append this BigInt to the specified hasher.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func appendHashes(to hasher: inout SipHasher)
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - init(exactly:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init?<T: BinaryFloatingPoint>(exactly source: T)
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - init(_:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init<T: BinaryFloatingPoint>(_ source: T)
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - negate() - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public mutating func negate()
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - -(_:_:) - -
    -
    -
    -
    -
    -
    -

    Subtract b from a and return the result.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func -(a: BigInt, b: BigInt) -> BigInt
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - -=(_:_:) - -
    -
    -
    -
    -
    -
    -

    Subtract b from a in place.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func -=(a: inout BigInt, b: BigInt)
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • - -
    -
    -
    -
    -
    -

    Divide this integer by y and return the resulting quotient and remainder.

    -
    -

    Requires

    - y > 0 - -
    -
    -

    Complexity

    - O(count^2) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func quotientAndRemainder(dividingBy y: BigInt) -> (quotient: BigInt, remainder: BigInt)
    - -
    -
    -
    -

    Return Value

    -

    (quotient, remainder) where quotient = floor(self/y), remainder = self - quotient * y

    -
    - -
    -
    -
  • -
  • -
    - - - - /(_:_:) - -
    -
    -
    -
    -
    -
    -

    Divide a by b and return the quotient. Traps if b is zero.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func /(a: BigInt, b: BigInt) -> BigInt
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - %(_:_:) - -
    -
    -
    -
    -
    -
    -

    Divide a by b and return the remainder. The result has the same sign as a.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func %(a: BigInt, b: BigInt) -> BigInt
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - modulus(_:) - -
    -
    -
    -
    -
    -
    -

    Return the result of a mod b. The result is always a nonnegative integer that is less than the absolute value of b.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func modulus(_ mod: BigInt) -> BigInt
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - /=(_:_:) - -
    -
    -
    -
    -
    -
    -

    Divide a by b storing the quotient in a.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func /=(a: inout BigInt, b: BigInt)
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - %=(_:_:) - -
    -
    -
    -
    -
    -
    -

    Divide a by b storing the remainder in a.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func %=(a: inout BigInt, b: BigInt)
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - init() - -
    -
    -
    -
    -
    -
    -

    Undocumented

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public struct BigInt: SignedInteger
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - init(_:) - -
    -
    -
    -
    -
    -
    -

    Initializes a new signed big integer with the same value as the specified unsigned big integer.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init(_ integer: BigUInt)
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - init(_:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init<T>(_ source: T) where T : BinaryInteger
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - init(exactly:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init?<T>(exactly source: T) where T : BinaryInteger
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - init(clamping:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init<T>(clamping source: T) where T : BinaryInteger
    - -
    -
    - -
    -
    -
  • -
  • - -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init<T>(truncatingIfNeeded source: T) where T : BinaryInteger
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - init(integerLiteral:) - -
    -
    -
    -
    -
    -
    -

    Initialize a new big integer from an integer literal.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init(integerLiteral value: Int64)
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - ==(_:_:) - -
    -
    -
    -
    -
    -
    -

    Return true iff a is equal to b.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func ==(a: BigInt, b: BigInt) -> Bool
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - <(_:_:) - -
    -
    -
    -
    -
    -
    -

    Return true iff a is less than b.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func <(a: BigInt, b: BigInt) -> Bool
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - init(_:radix:) - -
    -
    -
    -
    -
    -
    -

    Initialize a big integer from an ASCII representation in a given radix. Numerals above 9 are represented by -letters from the English alphabet.

    -
    -

    Requires

    - radix > 1 && radix < 36 - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init?<S: StringProtocol>(_ text: S, radix: Int = 10)
    - -
    -
    -
    -

    Return Value

    -

    The integer represented by text, or nil if text contains a character that does not represent a numeral in radix.

    -
    - -
    -
    -
  • -
-
-
-
    -
  • - -
    -
    -
    -
    -
    -

    Initialize a new big integer from a Unicode scalar. -The scalar must represent a decimal digit.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init(unicodeScalarLiteral value: UnicodeScalar)
    - -
    -
    - -
    -
    -
  • -
  • - -
    -
    -
    -
    -
    -

    Initialize a new big integer from an extended grapheme cluster. -The cluster must consist of a decimal digit.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init(extendedGraphemeClusterLiteral value: String)
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - init(stringLiteral:) - -
    -
    -
    -
    -
    -
    -

    Initialize a new big integer from a decimal number represented by a string literal of arbitrary length. -The string must contain only decimal digits.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init(stringLiteral value: StringLiteralType)
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - description - -
    -
    -
    -
    -
    -
    -

    Return the decimal representation of this integer.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var description: String
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • - -
    -
    -
    -
    -
    -

    Return the playground quick look representation of this integer.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var customPlaygroundQuickLook: PlaygroundQuickLook
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - *(_:_:) - -
    -
    -
    -
    -
    -
    -

    Multiply a with b and return the result.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func *(a: BigInt, b: BigInt) -> BigInt
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - *=(_:_:) - -
    -
    -
    -
    -
    -
    -

    Multiply a with b in place.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func *=(a: inout BigInt, b: BigInt)
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - advanced(by:) - -
    -
    -
    -
    -
    -
    -

    Returns self + n.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func advanced(by n: Stride) -> BigInt
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - distance(to:) - -
    -
    -
    -
    -
    -
    -

    Returns other - self.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func distance(to other: BigInt) -> Stride
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - &<<(_:_:) - -
    -
    -
    -
    -
    -
    -

    Undocumented

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public struct BigInt: SignedInteger
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - &<<=(_:_:) - -
    -
    -
    -
    -
    -
    -

    Undocumented

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public struct BigInt: SignedInteger
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - &>>(_:_:) - -
    -
    -
    -
    -
    -
    -

    Undocumented

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public struct BigInt: SignedInteger
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - &>>=(_:_:) - -
    -
    -
    -
    -
    -
    -

    Undocumented

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public struct BigInt: SignedInteger
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - <<(_:_:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func <<<Other: BinaryInteger>(lhs: BigInt, rhs: Other) -> BigInt
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - <<=(_:_:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func <<=<Other: BinaryInteger>(lhs: inout BigInt, rhs: Other)
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - >>(_:_:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func >><Other: BinaryInteger>(lhs: BigInt, rhs: Other) -> BigInt
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - >>=(_:_:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func >>=<Other: BinaryInteger>(lhs: inout BigInt, rhs: Other)
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • - -
    -
    -
    -
    -
    -

    Returns the greatest common divisor of a and b.

    -
    -

    Complexity

    - O(count^2) where count = max(a.count, b.count) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func greatestCommonDivisor(with b: BigInt) -> BigInt
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - inverse(_:) - -
    -
    -
    -
    -
    -
    -

    Returns the multiplicative inverse of this integer in modulo modulus arithmetic, -or nil if there is no such number.

    -
    -

    Requires

    - modulus.magnitude > 1 - -
    -
    -

    Complexity

    - O(count^3) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func inverse(_ modulus: BigInt) -> BigInt?
    - -
    -
    -
    -

    Return Value

    -

    If gcd(self, modulus) == 1, the value returned is an integer a < modulus such that (a * self) % modulus == 1. If self and modulus aren’t coprime, the return value is nil.

    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - squareRoot() - -
    -
    -
    -
    -
    -
    -

    Returns the integer square root of a big integer; i.e., the largest integer whose square isn’t greater than value.

    -
    -

    Requires

    - self >= 0 - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func squareRoot() -> BigInt
    - -
    -
    -
    -

    Return Value

    -

    floor(sqrt(self))

    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - init(from:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init(from decoder: Decoder) throws
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - encode(to:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func encode(to encoder: Encoder) throws
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - power(_:) - -
    -
    -
    -
    -
    -
    -

    Returns this integer raised to the power exponent.

    - -

    This function calculates the result by successively squaring the base while halving the exponent.

    -
    -

    Note

    - This function can be unreasonably expensive for large exponents, which is why exponent is - a simple integer value. If you want to calculate big exponents, you’ll probably need to use - the modulo arithmetic variant. - -
    -
    -

    See also

    - BigUInt.power(_:, modulus:) - -
    -
    -

    Complexity

    - O((exponent * self.count)^log2(3)) or somesuch. The result may require a large amount of memory, too. - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func power(_ exponent: Int) -> BigInt
    - -
    -
    -
    -

    Return Value

    -

    1 if exponent == 0, otherwise self raised to exponent. (This implies that 0.power(0) == 1.)

    -
    - -
    -
    -
  • -
  • -
    - - - - power(_:modulus:) - -
    -
    -
    -
    -
    -
    -

    Returns the remainder of this integer raised to the power exponent in modulo arithmetic under modulus.

    - -

    Uses the right-to-left binary method.

    -
    -

    Complexity

    - O(exponent.count * modulus.count^log2(3)) or somesuch - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func power(_ exponent: BigInt, modulus: BigInt) -> BigInt
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - +(_:_:) - -
    -
    -
    -
    -
    -
    -

    Add a to b and return the result.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func +(a: BigInt, b: BigInt) -> BigInt
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - +=(_:_:) - -
    -
    -
    -
    -
    -
    -

    Add b to a in place.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func +=(a: inout BigInt, b: BigInt)
    - -
    -
    - -
    -
    -
  • -
-
-
-
- -
-
- - - - diff --git a/Carthage/Checkouts/BigInt/docs/Structs/BigInt/Sign.html b/Carthage/Checkouts/BigInt/docs/Structs/BigInt/Sign.html deleted file mode 100644 index 2db1db2de..000000000 --- a/Carthage/Checkouts/BigInt/docs/Structs/BigInt/Sign.html +++ /dev/null @@ -1,167 +0,0 @@ - - - - Sign Enumeration Reference - - - - - - - - - - - - - - - - -
-

- - BigInt Docs - - (92% documented) -

- -

-

- -
-

- -

- - - View on GitHub - -

- -

- - - Install in Dash - -

-
- - - -
- -
- -
-
-

Sign

-

Undocumented

- -
-
- -
-
-
- -
-
- -
-
-
- -
-
- - - - diff --git a/Carthage/Checkouts/BigInt/docs/Structs/BigInt/Words.html b/Carthage/Checkouts/BigInt/docs/Structs/BigInt/Words.html deleted file mode 100644 index ba949c188..000000000 --- a/Carthage/Checkouts/BigInt/docs/Structs/BigInt/Words.html +++ /dev/null @@ -1,240 +0,0 @@ - - - - Words Structure Reference - - - - - - - - - - - - - - - - -
-

- - BigInt Docs - - (92% documented) -

- -

-

- -
-

- -

- - - View on GitHub - -

- -

- - - Install in Dash - -

-
- - - -
- -
- -
-
-

Words

-
-
-
public struct Words: RandomAccessCollection
- -
-
- -
-
- -
-
-
-
    -
  • -
    - - - - count - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var count: Int
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - indices - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var indices: Indices
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - startIndex - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var startIndex: Int
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - endIndex - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var endIndex: Int
    - -
    -
    - -
    -
    -
  • -
-
-
-
- -
-
- - - - diff --git a/Carthage/Checkouts/BigInt/docs/Structs/BigUInt.html b/Carthage/Checkouts/BigInt/docs/Structs/BigUInt.html deleted file mode 100644 index 8c502f7c2..000000000 --- a/Carthage/Checkouts/BigInt/docs/Structs/BigUInt.html +++ /dev/null @@ -1,3048 +0,0 @@ - - - - BigUInt Structure Reference - - - - - - - - - - - - - - - - -
-

- - BigInt Docs - - (92% documented) -

- -

-

- -
-

- -

- - - View on GitHub - -

- -

- - - Install in Dash - -

-
- - - -
- -
- -
-
-

BigUInt

-
-
-
public struct BigUInt: UnsignedInteger
- -
-
-

An arbitary precision unsigned integer type, also known as a big integer.

- -

Operations on big integers never overflow, but they may take a long time to execute. -The amount of memory (and address space) available is the only constraint to the magnitude of these numbers.

- -

This particular big integer type uses base-2^64 digits to represent integers; you can think of it as a wrapper -around Array<UInt64>. (In fact, BigUInt only uses an array if there are more than two digits.)

- -
-
- -
-
-
-
    -
  • -
    - - - - Word - -
    -
    -
    -
    -
    -
    -

    The type representing a digit in BigUInt‘s underlying number system.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public typealias Word = UInt
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - init() - -
    -
    -
    -
    -
    -
    -

    Initializes a new BigUInt with value 0.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init()
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - init(words:) - -
    -
    -
    -
    -
    -
    -

    Initializes a new BigUInt with the specified digits. The digits are ordered from least to most significant.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init(words: [Word])
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - ~(_:) - -
    -
    -
    -
    -
    -
    -

    Return the ones’ complement of a.

    -
    -

    Complexity

    - O(a.count) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static prefix func ~(a: BigUInt) -> BigUInt
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - |=(_:_:) - -
    -
    -
    -
    -
    -
    -

    Calculate the bitwise OR of a and b, and store the result in a.

    -
    -

    Complexity

    - O(max(a.count, b.count)) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func |= (a: inout BigUInt, b: BigUInt)
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - &=(_:_:) - -
    -
    -
    -
    -
    -
    -

    Calculate the bitwise AND of a and b and return the result.

    -
    -

    Complexity

    - O(max(a.count, b.count)) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func &= (a: inout BigUInt, b: BigUInt)
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - ^=(_:_:) - -
    -
    -
    -
    -
    -
    -

    Calculate the bitwise XOR of a and b and return the result.

    -
    -

    Complexity

    - O(max(a.count, b.count)) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func ^= (a: inout BigUInt, b: BigUInt)
    - -
    -
    - -
    -
    -
  • -
-
-
- -
    -
  • - -
    -
    -
    -
    -
    -

    Create a big integer consisting of width uniformly distributed random bits.

    -
    -

    Note

    - This function uses arc4random_buf to generate random bits. - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func randomInteger(withMaximumWidth width: Int) -> BigUInt
    - -
    -
    -
    -

    Return Value

    -

    A big integer less than 1 << width.

    -
    - -
    -
    -
  • -
  • - -
    -
    -
    -
    -
    -

    Create a big integer consisting of width-1 uniformly distributed random bits followed by a one bit.

    -
    -

    Note

    - This function uses arc4random_buf to generate random bits. - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func randomInteger(withExactWidth width: Int) -> BigUInt
    - -
    -
    -
    -

    Return Value

    -

    A random big integer whose width is width.

    -
    - -
    -
    -
  • -
  • - -
    -
    -
    -
    -
    -

    Create a uniformly distributed random integer that’s less than the specified limit.

    -
    -

    Note

    - This function uses arc4random_buf to generate random bits. - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func randomInteger(lessThan limit: BigUInt) -> BigUInt
    - -
    -
    -
    -

    Return Value

    -

    A random big integer that is less than limit.

    -
    - -
    -
    -
  • -
-
-
- -
    -
  • - -
    -
    -
    -
    -
    -

    Returns true iff this integer passes the strong probable prime test for the specified base.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func isStrongProbablePrime(_ base: BigUInt) -> Bool
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - isPrime(rounds:) - -
    -
    -
    -
    -
    -
    -

    Returns true if this integer is probably prime. Returns false if this integer is definitely not prime.

    - -

    This function performs a probabilistic Miller-Rabin Primality Test, consisting of rounds iterations, -each calculating the strong probable prime test for a random base. The number of rounds is 10 by default, -but you may specify your own choice.

    - -

    To speed things up, the function checks if self is divisible by the first few prime numbers before -diving into (slower) Miller-Rabin testing.

    - -

    Also, when self is less than 82 bits wide, isPrime does a deterministic test that is guaranteed to -return a correct result.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func isPrime(rounds: Int = 10) -> Bool
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - bitWidth - -
    -
    -
    -
    -
    -
    -

    The minimum number of bits required to represent this integer in binary.

    -
    -

    Complexity

    - O(1) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var bitWidth: Int
    - -
    -
    -
    -

    Return Value

    -

    floor(log2(2 * self + 1))

    -
    - -
    -
    -
  • -
  • -
    - - - - leadingZeroBitCount - -
    -
    -
    -
    -
    -
    -

    The number of leading zero bits in the binary representation of this integer in base 2^(Word.bitWidth). -This is useful when you need to normalize a BigUInt such that the top bit of its most significant word is 1.

    -
    -

    Note

    - 0 is considered to have zero leading zero bits. - -
    -
    -

    See also

    - width - -
    -
    -

    Complexity

    - O(1) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var leadingZeroBitCount: Int
    - -
    -
    -
    -

    Return Value

    -

    A value in 0...(Word.bitWidth - 1).

    -
    - -
    -
    -
  • -
  • -
    - - - - trailingZeroBitCount - -
    -
    -
    -
    -
    -
    -

    The number of trailing zero bits in the binary representation of this integer.

    -
    -

    Note

    - 0 is considered to have zero trailing zero bits. - -
    -
    -

    Complexity

    - O(count) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var trailingZeroBitCount: Int
    - -
    -
    -
    -

    Return Value

    -

    A value in 0...width.

    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - Words - -
    -
    -
    -
    -
    -
    - - See more -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public struct Words: RandomAccessCollection
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - words - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var words: Words
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - init(words:) - -
    -
    -
    -
    -
    -
    -

    Undocumented

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public struct BigUInt: UnsignedInteger
    - -
    -
    - -
    -
    -
  • -
-
-
- -
    -
  • -
    - - - - appendHashes(to:) - -
    -
    -
    -
    -
    -
    -

    Append this BigUInt to the specified hasher.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func appendHashes(to hasher: inout SipHasher)
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - init(exactly:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init?<T: BinaryFloatingPoint>(exactly source: T)
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - init(_:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init<T: BinaryFloatingPoint>(_ source: T)
    - -
    -
    - -
    -
    -
  • -
-
-
- -
    -
  • - -
    -
    -
    -
    -
    -

    Subtract other from this integer in place, and return a flag indicating if the operation caused an -arithmetic overflow. other is shifted shift digits to the left before being subtracted.

    -
    -

    Note

    - If the result indicates an overflow, then self becomes the twos’ complement of the absolute difference. - -
    -
    -

    Complexity

    - O(count) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public mutating func subtractReportingOverflow(_ b: BigUInt, shiftedBy shift: Int = 0) -> Bool
    - -
    -
    - -
    -
    -
  • -
  • - -
    -
    -
    -
    -
    -

    Subtract other from this integer, returning the difference and a flag indicating arithmetic overflow. -other is shifted shift digits to the left before being subtracted.

    -
    -

    Note

    - If overflow is true, then the result value is the twos’ complement of the absolute value of the difference. - -
    -
    -

    Complexity

    - O(count) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func subtractingReportingOverflow(_ other: BigUInt, shiftedBy shift: Int) -> (partialValue: BigUInt, overflow: Bool)
    - -
    -
    - -
    -
    -
  • -
  • - -
    -
    -
    -
    -
    -

    Subtracts other from self, returning the result and a flag indicating arithmetic overflow.

    -
    -

    Note

    - When the operation overflows, then partialValue is the twos’ complement of the absolute value of the difference. - -
    -
    -

    Complexity

    - O(count) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func subtractingReportingOverflow(_ other: BigUInt) -> (partialValue: BigUInt, overflow: Bool)
    - -
    -
    - -
    -
    -
  • -
  • - -
    -
    -
    -
    -
    -

    Subtract other from this integer in place. -other is shifted shift digits to the left before being subtracted.

    -
    -

    Requires

    - self >= other * 2^shift - -
    -
    -

    Complexity

    - O(count) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public mutating func subtract(_ other: BigUInt, shiftedBy shift: Int = 0)
    - -
    -
    - -
    -
    -
  • -
  • - -
    -
    -
    -
    -
    -

    Subtract b from this integer, and return the difference. -b is shifted shift digits to the left before being subtracted.

    -
    -

    Requires

    - self >= b * 2^shift - -
    -
    -

    Complexity

    - O(count) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func subtracting(_ other: BigUInt, shiftedBy shift: Int = 0) -> BigUInt
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - decrement(shiftedBy:) - -
    -
    -
    -
    -
    -
    -

    Decrement this integer by one.

    -
    -

    Requires

    - !isZero - -
    -
    -

    Complexity

    - O(count) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public mutating func decrement(shiftedBy shift: Int = 0)
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - -(_:_:) - -
    -
    -
    -
    -
    -
    -

    Subtract b from a and return the result.

    -
    -

    Requires

    - a >= b - -
    -
    -

    Complexity

    - O(a.count) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func -(a: BigUInt, b: BigUInt) -> BigUInt
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - -=(_:_:) - -
    -
    -
    -
    -
    -
    -

    Subtract b from a and store the result in a.

    -
    -

    Requires

    - a >= b - -
    -
    -

    Complexity

    - O(a.count) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func -=(a: inout BigUInt, b: BigUInt)
    - -
    -
    - -
    -
    -
  • -
-
-
- -
    -
  • - -
    -
    -
    -
    -
    -

    Divide this integer by y and return the resulting quotient and remainder.

    -
    -

    Requires

    - y > 0 - -
    -
    -

    Complexity

    - O(count^2) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func quotientAndRemainder(dividingBy y: BigUInt) -> (quotient: BigUInt, remainder: BigUInt)
    - -
    -
    -
    -

    Return Value

    -

    (quotient, remainder) where quotient = floor(self/y), remainder = self - quotient * y

    -
    - -
    -
    -
  • -
  • -
    - - - - /(_:_:) - -
    -
    -
    -
    -
    -
    -

    Divide x by y and return the quotient.

    -
    -

    Note

    - Use divided(by:) if you also need the remainder. - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func /(x: BigUInt, y: BigUInt) -> BigUInt
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - %(_:_:) - -
    -
    -
    -
    -
    -
    -

    Divide x by y and return the remainder.

    -
    -

    Note

    - Use divided(by:) if you also need the remainder. - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func %(x: BigUInt, y: BigUInt) -> BigUInt
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - /=(_:_:) - -
    -
    -
    -
    -
    -
    -

    Divide x by y and store the quotient in x.

    -
    -

    Note

    - Use divided(by:) if you also need the remainder. - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func /=(x: inout BigUInt, y: BigUInt)
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - %=(_:_:) - -
    -
    -
    -
    -
    -
    -

    Divide x by y and store the remainder in x.

    -
    -

    Note

    - Use divided(by:) if you also need the remainder. - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func %=(x: inout BigUInt, y: BigUInt)
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - init(exactly:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init?<T: BinaryInteger>(exactly source: T)
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - init(_:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init<T: BinaryInteger>(_ source: T)
    - -
    -
    - -
    -
    -
  • -
  • - -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init<T: BinaryInteger>(truncatingIfNeeded source: T)
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - init(clamping:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init<T: BinaryInteger>(clamping source: T)
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - init(integerLiteral:) - -
    -
    -
    -
    -
    -
    -

    Initialize a new big integer from an integer literal.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init(integerLiteral value: UInt64)
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - isSigned - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static var isSigned: Bool
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - signum() - -
    -
    -
    -
    -
    -
    -

    Returns -1 if this value is negative and 1 if it’s positive; otherwise, 0.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func signum() -> BigUInt
    - -
    -
    -
    -

    Return Value

    -

    The sign of this number, expressed as an integer of the same type.

    -
    - -
    -
    -
  • -
-
-
- -
    -
  • -
    - - - - subscript(_:) - -
    -
    -
    -
    -
    -
    -

    Get or set a digit at a given index.

    -
    -

    Note

    - Unlike a normal collection, it is OK for the index to be greater than or equal to endIndex. -The subscripting getter returns zero for indexes beyond the most significant digit. -Setting these extended digits automatically appends new elements to the underlying digit array. - -
    -
    -

    Requires

    - index >= 0 - -
    -
    -

    Complexity

    - The getter is O(1). The setter is O(1) if the conditions below are true; otherwise it’s O(count). - -
      -
    • The integer’s storage is not shared with another integer
    • -
    • The integer wasn’t created as a slice of another integer
    • -
    • index < count
    • -
    - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    subscript(_ index: Int) -> Word
    - -
    -
    - -
    -
    -
  • -
-
-
- -
    -
  • -
    - - - - compare(_:_:) - -
    -
    -
    -
    -
    -
    -

    Compare a to b and return an NSComparisonResult indicating their order.

    -
    -

    Complexity

    - O(count) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func compare(_ a: BigUInt, _ b: BigUInt) -> ComparisonResult
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - ==(_:_:) - -
    -
    -
    -
    -
    -
    -

    Return true iff a is equal to b.

    -
    -

    Complexity

    - O(count) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func ==(a: BigUInt, b: BigUInt) -> Bool
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - <(_:_:) - -
    -
    -
    -
    -
    -
    -

    Return true iff a is less than b.

    -
    -

    Complexity

    - O(count) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func <(a: BigUInt, b: BigUInt) -> Bool
    - -
    -
    - -
    -
    -
  • -
-
-
- -
    -
  • -
    - - - - init(_:radix:) - -
    -
    -
    -
    -
    -
    -

    Initialize a big integer from an ASCII representation in a given radix. Numerals above 9 are represented by -letters from the English alphabet.

    -
    -

    Requires

    - radix > 1 && radix < 36 - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init?(_ text: String, radix: Int = 10)
    - -
    -
    -
    -

    Return Value

    -

    The integer represented by text, or nil if text contains a character that does not represent a numeral in radix.

    -
    - -
    -
    -
  • -
  • -
    - - - - init(_:radix:) - -
    -
    -
    -
    -
    -
    -

    Undocumented

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public struct BigUInt: UnsignedInteger
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • - -
    -
    -
    -
    -
    -

    Initialize a new big integer from a Unicode scalar. -The scalar must represent a decimal digit.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init(unicodeScalarLiteral value: UnicodeScalar)
    - -
    -
    - -
    -
    -
  • -
  • - -
    -
    -
    -
    -
    -

    Initialize a new big integer from an extended grapheme cluster. -The cluster must consist of a decimal digit.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init(extendedGraphemeClusterLiteral value: String)
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - init(stringLiteral:) - -
    -
    -
    -
    -
    -
    -

    Initialize a new big integer from a decimal number represented by a string literal of arbitrary length. -The string must contain only decimal digits.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init(stringLiteral value: StringLiteralType)
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - description - -
    -
    -
    -
    -
    -
    -

    Return the decimal representation of this integer.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var description: String
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • - -
    -
    -
    -
    -
    -

    Return the playground quick look representation of this integer.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var customPlaygroundQuickLook: PlaygroundQuickLook
    - -
    -
    - -
    -
    -
  • -
-
-
- -
    -
  • -
    - - - - init(_:) - -
    -
    -
    -
    -
    -
    -

    Undocumented

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public struct BigUInt: UnsignedInteger
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - init(_:) - -
    -
    -
    -
    -
    -
    -

    Initializes an integer from the bits stored inside a piece of Data. -The data is assumed to be in network (big-endian) byte order.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init(_ data: Data)
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - serialize() - -
    -
    -
    -
    -
    -
    -

    Return a Data value that contains the base-256 representation of this integer, in network (big-endian) byte order.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func serialize() -> Data
    - -
    -
    - -
    -
    -
  • -
-
-
- -
    -
  • -
    - - - - multiply(byWord:) - -
    -
    -
    -
    -
    -
    -

    Multiply this big integer by a single word, and store the result in place of the original big integer.

    -
    -

    Complexity

    - O(count) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public mutating func multiply(byWord y: Word)
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - multiplied(byWord:) - -
    -
    -
    -
    -
    -
    -

    Multiply this big integer by a single Word, and return the result.

    -
    -

    Complexity

    - O(count) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func multiplied(byWord y: Word) -> BigUInt
    - -
    -
    - -
    -
    -
  • -
  • - -
    -
    -
    -
    -
    -

    Multiply x by y, and add the result to this integer, optionally shifted shift words to the left.

    -
    -

    Note

    - This is the fused multiply/shift/add operation; it is more efficient than doing the components -individually. (The fused operation doesn’t need to allocate space for temporary big integers.) - -
    -
    -

    Complexity

    - O(count) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public mutating func multiplyAndAdd(_ x: BigUInt, _ y: Word, shiftedBy shift: Int = 0)
    - -
    -
    -
    -

    Return Value

    -

    self is set to self + (x * y) << (shift * 2^Word.bitWidth)

    -
    - -
    -
    -
  • -
  • -
    - - - - multiplied(by:) - -
    -
    -
    -
    -
    -
    -

    Multiply this integer by y and return the result.

    -
    -

    Note

    - This uses the naive O(n^2) multiplication algorithm unless both arguments have more than -BigUInt.directMultiplicationLimit words. - -
    -
    -

    Complexity

    - O(n^log2(3)) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func multiplied(by y: BigUInt) -> BigUInt
    - -
    -
    - -
    -
    -
  • -
  • - -
    -
    -
    -
    -
    -

    Multiplication switches to an asymptotically better recursive algorithm when arguments have more words than this limit.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static var directMultiplicationLimit: Int = 1024
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - *(_:_:) - -
    -
    -
    -
    -
    -
    -

    Multiply a by b and return the result.

    -
    -

    Note

    - This uses the naive O(n^2) multiplication algorithm unless both arguments have more than -BigUInt.directMultiplicationLimit words. - -
    -
    -

    Complexity

    - O(n^log2(3)) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func *(x: BigUInt, y: BigUInt) -> BigUInt
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - *=(_:_:) - -
    -
    -
    -
    -
    -
    -

    Multiply a by b and store the result in a.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func *=(a: inout BigUInt, b: BigUInt)
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - Stride - -
    -
    -
    -
    -
    -
    -

    A type that can represent the distance between two values ofa BigUInt.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public typealias Stride = BigInt
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - advanced(by:) - -
    -
    -
    -
    -
    -
    -

    Adds n to self and returns the result. Traps if the result would be less than zero.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func advanced(by n: BigInt) -> BigUInt
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - distance(to:) - -
    -
    -
    -
    -
    -
    -

    Returns the (potentially negative) difference between self and other as a BigInt. Never traps.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func distance(to other: BigUInt) -> BigInt
    - -
    -
    - -
    -
    -
  • -
-
-
- -
    -
  • -
    - - - - >>=(_:_:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func >>=<Other: BinaryInteger>(lhs: inout BigUInt, rhs: Other)
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - <<=(_:_:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func <<=<Other: BinaryInteger>(lhs: inout BigUInt, rhs: Other)
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - >>(_:_:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func >><Other: BinaryInteger>(lhs: BigUInt, rhs: Other) -> BigUInt
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - <<(_:_:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func <<<Other: BinaryInteger>(lhs: BigUInt, rhs: Other) -> BigUInt
    - -
    -
    - -
    -
    -
  • -
-
-
- -
    -
  • - -
    -
    -
    -
    -
    -

    Returns the greatest common divisor of self and b.

    -
    -

    Complexity

    - O(count^2) where count = max(self.count, b.count) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func greatestCommonDivisor(with b: BigUInt) -> BigUInt
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - inverse(_:) - -
    -
    -
    -
    -
    -
    -

    Returns the multiplicative inverse of this integer in modulo modulus arithmetic, -or nil if there is no such number.

    -
    -

    Requires

    - modulus > 1 - -
    -
    -

    Complexity

    - O(count^3) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func inverse(_ modulus: BigUInt) -> BigUInt?
    - -
    -
    -
    -

    Return Value

    -

    If gcd(self, modulus) == 1, the value returned is an integer a < modulus such that (a * self) % modulus == 1. If self and modulus aren’t coprime, the return value is nil.

    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - squareRoot() - -
    -
    -
    -
    -
    -
    -

    Returns the integer square root of a big integer; i.e., the largest integer whose square isn’t greater than value.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func squareRoot() -> BigUInt
    - -
    -
    -
    -

    Return Value

    -

    floor(sqrt(self))

    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - init(from:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init(from decoder: Decoder) throws
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - encode(to:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func encode(to encoder: Encoder) throws
    - -
    -
    - -
    -
    -
  • -
-
-
- -
    -
  • -
    - - - - power(_:) - -
    -
    -
    -
    -
    -
    -

    Returns this integer raised to the power exponent.

    - -

    This function calculates the result by successively squaring the base while halving the exponent.

    -
    -

    Note

    - This function can be unreasonably expensive for large exponents, which is why exponent is - a simple integer value. If you want to calculate big exponents, you’ll probably need to use - the modulo arithmetic variant. - -
    -
    -

    See also

    - BigUInt.power(_:, modulus:) - -
    -
    -

    Complexity

    - O((exponent * self.count)^log2(3)) or somesuch. The result may require a large amount of memory, too. - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func power(_ exponent: Int) -> BigUInt
    - -
    -
    -
    -

    Return Value

    -

    1 if exponent == 0, otherwise self raised to exponent. (This implies that 0.power(0) == 1.)

    -
    - -
    -
    -
  • -
  • -
    - - - - power(_:modulus:) - -
    -
    -
    -
    -
    -
    -

    Returns the remainder of this integer raised to the power exponent in modulo arithmetic under modulus.

    - -

    Uses the right-to-left binary method.

    -
    -

    Complexity

    - O(exponent.count * modulus.count^log2(3)) or somesuch - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func power(_ exponent: BigUInt, modulus: BigUInt) -> BigUInt
    - -
    -
    - -
    -
    -
  • -
-
-
- -
    -
  • -
    - - - - +(_:_:) - -
    -
    -
    -
    -
    -
    -

    Add a and b together and return the result.

    -
    -

    Complexity

    - O(max(a.count, b.count)) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func +(a: BigUInt, b: BigUInt) -> BigUInt
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - +=(_:_:) - -
    -
    -
    -
    -
    -
    -

    Add a and b together, and store the sum in a.

    -
    -

    Complexity

    - O(max(a.count, b.count)) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func +=(a: inout BigUInt, b: BigUInt)
    - -
    -
    - -
    -
    -
  • -
-
-
-
- -
-
- - - - diff --git a/Carthage/Checkouts/BigInt/docs/Structs/BigUInt/Words.html b/Carthage/Checkouts/BigInt/docs/Structs/BigUInt/Words.html deleted file mode 100644 index b0dda68e0..000000000 --- a/Carthage/Checkouts/BigInt/docs/Structs/BigUInt/Words.html +++ /dev/null @@ -1,182 +0,0 @@ - - - - Words Structure Reference - - - - - - - - - - - - - - - - -
-

- - BigInt Docs - - (92% documented) -

- -

-

- -
-

- -

- - - View on GitHub - -

- -

- - - Install in Dash - -

-
- - - -
- -
- -
-
-

Words

-
-
-
public struct Words: RandomAccessCollection
- -
-
- -
-
- -
-
-
-
    -
  • -
    - - - - startIndex - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var startIndex: Int
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - endIndex - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var endIndex: Int
    - -
    -
    - -
    -
    -
  • -
-
-
-
- -
-
- - - - diff --git a/Carthage/Checkouts/BigInt/docs/badge.svg b/Carthage/Checkouts/BigInt/docs/badge.svg deleted file mode 100644 index 658cf7ab0..000000000 --- a/Carthage/Checkouts/BigInt/docs/badge.svg +++ /dev/null @@ -1 +0,0 @@ -documentationdocumentation92%92% \ No newline at end of file diff --git a/Carthage/Checkouts/BigInt/docs/css/highlight.css b/Carthage/Checkouts/BigInt/docs/css/highlight.css deleted file mode 100644 index d0db0e13b..000000000 --- a/Carthage/Checkouts/BigInt/docs/css/highlight.css +++ /dev/null @@ -1,200 +0,0 @@ -/* Credit to https://gist.github.com/wataru420/2048287 */ -.highlight { - /* Comment */ - /* Error */ - /* Keyword */ - /* Operator */ - /* Comment.Multiline */ - /* Comment.Preproc */ - /* Comment.Single */ - /* Comment.Special */ - /* Generic.Deleted */ - /* Generic.Deleted.Specific */ - /* Generic.Emph */ - /* Generic.Error */ - /* Generic.Heading */ - /* Generic.Inserted */ - /* Generic.Inserted.Specific */ - /* Generic.Output */ - /* Generic.Prompt */ - /* Generic.Strong */ - /* Generic.Subheading */ - /* Generic.Traceback */ - /* Keyword.Constant */ - /* Keyword.Declaration */ - /* Keyword.Pseudo */ - /* Keyword.Reserved */ - /* Keyword.Type */ - /* Literal.Number */ - /* Literal.String */ - /* Name.Attribute */ - /* Name.Builtin */ - /* Name.Class */ - /* Name.Constant */ - /* Name.Entity */ - /* Name.Exception */ - /* Name.Function */ - /* Name.Namespace */ - /* Name.Tag */ - /* Name.Variable */ - /* Operator.Word */ - /* Text.Whitespace */ - /* Literal.Number.Float */ - /* Literal.Number.Hex */ - /* Literal.Number.Integer */ - /* Literal.Number.Oct */ - /* Literal.String.Backtick */ - /* Literal.String.Char */ - /* Literal.String.Doc */ - /* Literal.String.Double */ - /* Literal.String.Escape */ - /* Literal.String.Heredoc */ - /* Literal.String.Interpol */ - /* Literal.String.Other */ - /* Literal.String.Regex */ - /* Literal.String.Single */ - /* Literal.String.Symbol */ - /* Name.Builtin.Pseudo */ - /* Name.Variable.Class */ - /* Name.Variable.Global */ - /* Name.Variable.Instance */ - /* Literal.Number.Integer.Long */ } - .highlight .c { - color: #999988; - font-style: italic; } - .highlight .err { - color: #a61717; - background-color: #e3d2d2; } - .highlight .k { - color: #000000; - font-weight: bold; } - .highlight .o { - color: #000000; - font-weight: bold; } - .highlight .cm { - color: #999988; - font-style: italic; } - .highlight .cp { - color: #999999; - font-weight: bold; } - .highlight .c1 { - color: #999988; - font-style: italic; } - .highlight .cs { - color: #999999; - font-weight: bold; - font-style: italic; } - .highlight .gd { - color: #000000; - background-color: #ffdddd; } - .highlight .gd .x { - color: #000000; - background-color: #ffaaaa; } - .highlight .ge { - color: #000000; - font-style: italic; } - .highlight .gr { - color: #aa0000; } - .highlight .gh { - color: #999999; } - .highlight .gi { - color: #000000; - background-color: #ddffdd; } - .highlight .gi .x { - color: #000000; - background-color: #aaffaa; } - .highlight .go { - color: #888888; } - .highlight .gp { - color: #555555; } - .highlight .gs { - font-weight: bold; } - .highlight .gu { - color: #aaaaaa; } - .highlight .gt { - color: #aa0000; } - .highlight .kc { - color: #000000; - font-weight: bold; } - .highlight .kd { - color: #000000; - font-weight: bold; } - .highlight .kp { - color: #000000; - font-weight: bold; } - .highlight .kr { - color: #000000; - font-weight: bold; } - .highlight .kt { - color: #445588; } - .highlight .m { - color: #009999; } - .highlight .s { - color: #d14; } - .highlight .na { - color: #008080; } - .highlight .nb { - color: #0086B3; } - .highlight .nc { - color: #445588; - font-weight: bold; } - .highlight .no { - color: #008080; } - .highlight .ni { - color: #800080; } - .highlight .ne { - color: #990000; - font-weight: bold; } - .highlight .nf { - color: #990000; } - .highlight .nn { - color: #555555; } - .highlight .nt { - color: #000080; } - .highlight .nv { - color: #008080; } - .highlight .ow { - color: #000000; - font-weight: bold; } - .highlight .w { - color: #bbbbbb; } - .highlight .mf { - color: #009999; } - .highlight .mh { - color: #009999; } - .highlight .mi { - color: #009999; } - .highlight .mo { - color: #009999; } - .highlight .sb { - color: #d14; } - .highlight .sc { - color: #d14; } - .highlight .sd { - color: #d14; } - .highlight .s2 { - color: #d14; } - .highlight .se { - color: #d14; } - .highlight .sh { - color: #d14; } - .highlight .si { - color: #d14; } - .highlight .sx { - color: #d14; } - .highlight .sr { - color: #009926; } - .highlight .s1 { - color: #d14; } - .highlight .ss { - color: #990073; } - .highlight .bp { - color: #999999; } - .highlight .vc { - color: #008080; } - .highlight .vg { - color: #008080; } - .highlight .vi { - color: #008080; } - .highlight .il { - color: #009999; } diff --git a/Carthage/Checkouts/BigInt/docs/css/jazzy.css b/Carthage/Checkouts/BigInt/docs/css/jazzy.css deleted file mode 100644 index c83db5bfc..000000000 --- a/Carthage/Checkouts/BigInt/docs/css/jazzy.css +++ /dev/null @@ -1,368 +0,0 @@ -*, *:before, *:after { - box-sizing: inherit; } - -body { - margin: 0; - background: #fff; - color: #333; - font: 16px/1.7 "Helvetica Neue", Helvetica, Arial, sans-serif; - letter-spacing: .2px; - -webkit-font-smoothing: antialiased; - box-sizing: border-box; } - -h1 { - font-size: 2rem; - font-weight: 700; - margin: 1.275em 0 0.6em; } - -h2 { - font-size: 1.75rem; - font-weight: 700; - margin: 1.275em 0 0.3em; } - -h3 { - font-size: 1.5rem; - font-weight: 700; - margin: 1em 0 0.3em; } - -h4 { - font-size: 1.25rem; - font-weight: 700; - margin: 1.275em 0 0.85em; } - -h5 { - font-size: 1rem; - font-weight: 700; - margin: 1.275em 0 0.85em; } - -h6 { - font-size: 1rem; - font-weight: 700; - margin: 1.275em 0 0.85em; - color: #777; } - -p { - margin: 0 0 1em; } - -ul, ol { - padding: 0 0 0 2em; - margin: 0 0 0.85em; } - -blockquote { - margin: 0 0 0.85em; - padding: 0 15px; - color: #858585; - border-left: 4px solid #e5e5e5; } - -img { - max-width: 100%; } - -a { - color: #4183c4; - text-decoration: none; } - a:hover, a:focus { - outline: 0; - text-decoration: underline; } - -table { - background: #fff; - width: 100%; - border-collapse: collapse; - border-spacing: 0; - overflow: auto; - margin: 0 0 0.85em; } - -tr:nth-child(2n) { - background-color: #fbfbfb; } - -th, td { - padding: 6px 13px; - border: 1px solid #ddd; } - -pre { - margin: 0 0 1.275em; - padding: .85em 1em; - overflow: auto; - background: #f7f7f7; - font-size: .85em; - font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; } - -code { - font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; } - -p > code, li > code { - background: #f7f7f7; - padding: .2em; } - p > code:before, p > code:after, li > code:before, li > code:after { - letter-spacing: -.2em; - content: "\00a0"; } - -pre code { - padding: 0; - white-space: pre; } - -.content-wrapper { - display: flex; - flex-direction: column; } - @media (min-width: 768px) { - .content-wrapper { - flex-direction: row; } } - -.header { - display: flex; - padding: 8px; - font-size: 0.875em; - background: #444; - color: #999; } - -.header-col { - margin: 0; - padding: 0 8px; } - -.header-col--primary { - flex: 1; } - -.header-link { - color: #fff; } - -.header-icon { - padding-right: 6px; - vertical-align: -4px; - height: 16px; } - -.breadcrumbs { - font-size: 0.875em; - padding: 8px 16px; - margin: 0; - background: #fbfbfb; - border-bottom: 1px solid #ddd; } - -.carat { - height: 10px; - margin: 0 5px; } - -.navigation { - order: 2; } - @media (min-width: 768px) { - .navigation { - order: 1; - width: 25%; - max-width: 300px; - padding-bottom: 64px; - overflow: hidden; - word-wrap: normal; - background: #fbfbfb; - border-right: 1px solid #ddd; } } - -.nav-groups { - list-style-type: none; - padding-left: 0; } - -.nav-group-name { - border-bottom: 1px solid #ddd; - padding: 8px 0 8px 16px; } - -.nav-group-name-link { - color: #333; } - -.nav-group-tasks { - margin: 8px 0; - padding: 0 0 0 8px; } - -.nav-group-task { - font-size: 1em; - list-style-type: none; - white-space: nowrap; } - -.nav-group-task-link { - color: #808080; } - -.main-content { - order: 1; } - @media (min-width: 768px) { - .main-content { - order: 2; - flex: 1; - padding-bottom: 60px; } } - -.section { - padding: 0 32px; - border-bottom: 1px solid #ddd; } - -.section-content { - max-width: 834px; - margin: 0 auto; - padding: 16px 0; } - -.section-name { - color: #666; - display: block; } - -.declaration .highlight { - overflow-x: initial; - padding: 8px 0; - margin: 0; - background-color: transparent; - border: none; } - -.task-group-section { - border-top: 1px solid #ddd; } - -.task-group { - padding-top: 0px; } - -.task-name-container a[name]:before { - content: ""; - display: block; } - -.item-container { - padding: 0; } - -.item { - padding-top: 8px; - width: 100%; - list-style-type: none; } - .item a[name]:before { - content: ""; - display: block; } - .item .token { - padding-left: 3px; - margin-left: 0px; - font-size: 1rem; } - .item .declaration-note { - font-size: .85em; - color: #808080; - font-style: italic; } - -.pointer-container { - border-bottom: 1px solid #ddd; - left: -23px; - padding-bottom: 13px; - position: relative; - width: 110%; } - -.pointer { - left: 21px; - top: 7px; - display: block; - position: absolute; - width: 12px; - height: 12px; - border-left: 1px solid #ddd; - border-top: 1px solid #ddd; - background: #fff; - transform: rotate(45deg); } - -.height-container { - display: none; - position: relative; - width: 100%; - overflow: hidden; } - .height-container .section { - background: #fff; - border: 1px solid #ddd; - border-top-width: 0; - padding-top: 10px; - padding-bottom: 5px; - padding: 8px 16px; } - -.aside, .language { - padding: 6px 12px; - margin: 12px 0; - border-left: 5px solid #dddddd; - overflow-y: hidden; } - .aside .aside-title, .language .aside-title { - font-size: 9px; - letter-spacing: 2px; - text-transform: uppercase; - padding-bottom: 0; - margin: 0; - color: #aaa; - -webkit-user-select: none; } - .aside p:last-child, .language p:last-child { - margin-bottom: 0; } - -.language { - border-left: 5px solid #cde9f4; } - .language .aside-title { - color: #4183c4; } - -.aside-warning { - border-left: 5px solid #ff6666; } - .aside-warning .aside-title { - color: #ff0000; } - -.graybox { - border-collapse: collapse; - width: 100%; } - .graybox p { - margin: 0; - word-break: break-word; - min-width: 50px; } - .graybox td { - border: 1px solid #ddd; - padding: 5px 25px 5px 10px; - vertical-align: middle; } - .graybox tr td:first-of-type { - text-align: right; - padding: 7px; - vertical-align: top; - word-break: normal; - width: 40px; } - -.slightly-smaller { - font-size: 0.9em; } - -.footer { - padding: 8px 16px; - background: #444; - color: #ddd; - font-size: 0.8em; } - .footer p { - margin: 8px 0; } - .footer a { - color: #fff; } - -html.dash .header, html.dash .breadcrumbs, html.dash .navigation { - display: none; } -html.dash .height-container { - display: block; } - -form[role=search] input { - font: 16px/1.7 "Helvetica Neue", Helvetica, Arial, sans-serif; - font-size: 14px; - line-height: 24px; - padding: 0 10px; - margin: 0; - border: none; - border-radius: 1em; } - .loading form[role=search] input { - background: white url(../img/spinner.gif) center right 4px no-repeat; } -form[role=search] .tt-menu { - margin: 0; - min-width: 300px; - background: #fbfbfb; - color: #333; - border: 1px solid #ddd; } -form[role=search] .tt-highlight { - font-weight: bold; } -form[role=search] .tt-suggestion { - font: 16px/1.7 "Helvetica Neue", Helvetica, Arial, sans-serif; - padding: 0 8px; } - form[role=search] .tt-suggestion span { - display: table-cell; - white-space: nowrap; } - form[role=search] .tt-suggestion .doc-parent-name { - width: 100%; - text-align: right; - font-weight: normal; - font-size: 0.9em; - padding-left: 16px; } -form[role=search] .tt-suggestion:hover, -form[role=search] .tt-suggestion.tt-cursor { - cursor: pointer; - background-color: #4183c4; - color: #fff; } -form[role=search] .tt-suggestion:hover .doc-parent-name, -form[role=search] .tt-suggestion.tt-cursor .doc-parent-name { - color: #fff; } diff --git a/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Info.plist b/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Info.plist deleted file mode 100644 index dbf7f7a9b..000000000 --- a/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Info.plist +++ /dev/null @@ -1,20 +0,0 @@ - - - - - CFBundleIdentifier - com.jazzy.bigint - CFBundleName - BigInt - DocSetPlatformFamily - bigint - isDashDocset - - dashIndexFilePath - index.html - isJavaScriptEnabled - - DashDocSetFamily - dashtoc - - diff --git a/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/Extensions.html b/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/Extensions.html deleted file mode 100644 index b9203ad28..000000000 --- a/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/Extensions.html +++ /dev/null @@ -1,176 +0,0 @@ - - - - Extensions Reference - - - - - - - - - - - - - - - -
-

- - BigInt Docs - - (92% documented) -

- -

-

- -
-

- -

- - - View on GitHub - -

- -

- - - Install in Dash - -

-
- - - -
- -
- -
-
-

Extensions

-

The following extensions are available globally.

- -
-
- -
-
-
-
    -
  • -
    - - - - BinaryFloatingPoint - -
    -
    -
    -
    -
    -
    - - See more -
    -
    -

    Declaration

    -
    -

    Swift

    -
    protocol BinaryFloatingPoint : FloatingPoint, ExpressibleByFloatLiteral
    - -
    -
    -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - String - -
    -
    -
    -
    -
    -
    - - See more -
    -
    -

    Declaration

    -
    -

    Swift

    -
    struct String
    - -
    -
    -
    -
    -
  • -
-
-
-
- -
-
- - - - diff --git a/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/Extensions/BinaryFloatingPoint.html b/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/Extensions/BinaryFloatingPoint.html deleted file mode 100644 index 648ecee7b..000000000 --- a/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/Extensions/BinaryFloatingPoint.html +++ /dev/null @@ -1,184 +0,0 @@ - - - - BinaryFloatingPoint Extension Reference - - - - - - - - - - - - - - - - -
-

- - BigInt Docs - - (92% documented) -

- -

-

- -
-

- -

- - - View on GitHub - -

- -

- - - Install in Dash - -

-
- - - -
- -
- -
-
-

BinaryFloatingPoint

-
-
-
protocol BinaryFloatingPoint : FloatingPoint, ExpressibleByFloatLiteral
- -
-
- -
-
- -
-
-
-
    -
  • -
    - - - - init(_:) - -
    -
    -
    -
    -
    -
    -

    Undocumented

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    protocol BinaryFloatingPoint : FloatingPoint, ExpressibleByFloatLiteral
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - init(_:) - -
    -
    -
    -
    -
    -
    -

    Undocumented

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    protocol BinaryFloatingPoint : FloatingPoint, ExpressibleByFloatLiteral
    - -
    -
    - -
    -
    -
  • -
-
-
-
- -
-
- - - - diff --git a/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/Extensions/String.html b/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/Extensions/String.html deleted file mode 100644 index 3b61515d6..000000000 --- a/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/Extensions/String.html +++ /dev/null @@ -1,245 +0,0 @@ - - - - String Extension Reference - - - - - - - - - - - - - - - - -
-

- - BigInt Docs - - (92% documented) -

- -

-

- -
-

- -

- - - View on GitHub - -

- -

- - - Install in Dash - -

-
- - - -
- -
- -
-
-

String

-
-
-
struct String
- -
-
- -
-
- -
-
-
-
    -
  • -
    - - - - init(_:) - -
    -
    -
    -
    -
    -
    -

    Initialize a new string with the base-10 representation of an unsigned big integer.

    -
    -

    Complexity

    - O(v.count^2) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init(_ v: BigUInt)
    - -
    -
    - -
    -
    -
  • -
  • - -
    -
    -
    -
    -
    -

    Initialize a new string representing an unsigned big integer in the given radix (base).

    - -

    Numerals greater than 9 are represented as letters from the English alphabet, -starting with a if uppercase is false or A otherwise.

    -
    -

    Requires

    - radix > 1 && radix <= 36 - -
    -
    -

    Complexity

    - O(count) when radix is a power of two; otherwise O(count^2). - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init(_ v: BigUInt, radix: Int, uppercase: Bool = false)
    - -
    -
    - -
    -
    -
  • -
  • - -
    -
    -
    -
    -
    -

    Initialize a new string representing a signed big integer in the given radix (base).

    - -

    Numerals greater than 9 are represented as letters from the English alphabet, -starting with a if uppercase is false or A otherwise.

    -
    -

    Requires

    - radix > 1 && radix <= 36 - -
    -
    -

    Complexity

    - O(count) when radix is a power of two; otherwise O(count^2). - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init(_ value: BigInt, radix: Int = 10, uppercase: Bool = false)
    - -
    -
    - -
    -
    -
  • -
-
-
-
- -
-
- - - - diff --git a/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/Structs.html b/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/Structs.html deleted file mode 100644 index 366be84d2..000000000 --- a/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/Structs.html +++ /dev/null @@ -1,211 +0,0 @@ - - - - Structures Reference - - - - - - - - - - - - - - - -
-

- - BigInt Docs - - (92% documented) -

- -

-

- -
-

- -

- - - View on GitHub - -

- -

- - - Install in Dash - -

-
- - - -
- -
- -
-
-

Structures

-

The following structures are available globally.

- -
-
- -
-
-
-
    -
  • -
    - - - - BigUInt - -
    -
    -
    -
    -
    -
    -

    An arbitary precision unsigned integer type, also known as a big integer.

    - -

    Operations on big integers never overflow, but they may take a long time to execute. -The amount of memory (and address space) available is the only constraint to the magnitude of these numbers.

    - -

    This particular big integer type uses base-2^64 digits to represent integers; you can think of it as a wrapper -around Array<UInt64>. (In fact, BigUInt only uses an array if there are more than two digits.)

    - - See more -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public struct BigUInt: UnsignedInteger
    - -
    -
    - -
    -
    -
  • -
-
-
-
- - - -

BigInt

-
-
-
    -
  • -
    - - - - BigInt - -
    -
    -
    -
    -
    -
    -

    An arbitary precision signed integer type, also known as a big integer.

    - -

    Operations on big integers never overflow, but they might take a long time to execute. -The amount of memory (and address space) available is the only constraint to the magnitude of these numbers.

    - -

    This particular big integer type uses base-2^64 digits to represent integers.

    - -

    BigInt is essentially a tiny wrapper that extends BigUInt with a sign bit and provides signed integer -operations. Both the underlying absolute value and the negative/positive flag are available as read-write -properties.

    - -

    Not all algorithms of BigUInt are available for BigInt values; for example, there is no square root or -primality test for signed integers. When you need to call one of these, just extract the absolute value:

    -
    BigInt(255).abs.isPrime()   // Returns false
    -
    - - See more -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public struct BigInt: SignedInteger
    - -
    -
    - -
    -
    -
  • -
-
-
-
- -
-
- - - - diff --git a/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/Structs/BigInt.html b/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/Structs/BigInt.html deleted file mode 100644 index 7bc104afd..000000000 --- a/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/Structs/BigInt.html +++ /dev/null @@ -1,2427 +0,0 @@ - - - - BigInt Structure Reference - - - - - - - - - - - - - - - - -
-

- - BigInt Docs - - (92% documented) -

- -

-

- -
-

- -

- - - View on GitHub - -

- -

- - - Install in Dash - -

-
- - - -
- -
- -
-
-

BigInt

-
-
-
public struct BigInt: SignedInteger
- -
-
-

An arbitary precision signed integer type, also known as a big integer.

- -

Operations on big integers never overflow, but they might take a long time to execute. -The amount of memory (and address space) available is the only constraint to the magnitude of these numbers.

- -

This particular big integer type uses base-2^64 digits to represent integers.

- -

BigInt is essentially a tiny wrapper that extends BigUInt with a sign bit and provides signed integer -operations. Both the underlying absolute value and the negative/positive flag are available as read-write -properties.

- -

Not all algorithms of BigUInt are available for BigInt values; for example, there is no square root or -primality test for signed integers. When you need to call one of these, just extract the absolute value:

-
BigInt(255).abs.isPrime()   // Returns false
-
- -
-
- -
-
-
-
    -
  • -
    - - - - Sign - -
    -
    -
    -
    -
    -
    -

    Undocumented

    - - See more -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public struct BigInt: SignedInteger
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - Word - -
    -
    -
    -
    -
    -
    -

    The type representing a digit in BigInt‘s underlying number system.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public typealias Word = BigUInt.Word
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - isSigned - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static var isSigned: Bool
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - magnitude - -
    -
    -
    -
    -
    -
    -

    The absolute value of this integer.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var magnitude: BigUInt
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - sign - -
    -
    -
    -
    -
    -
    -

    True iff the value of this integer is negative.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var sign: Sign
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - init(sign:magnitude:) - -
    -
    -
    -
    -
    -
    -

    Initializes a new big integer with the provided absolute number and sign flag.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init(sign: Sign, magnitude: BigUInt)
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - isZero - -
    -
    -
    -
    -
    -
    -

    Return true iff this integer is zero.

    -
    -

    Complexity

    - O(1) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var isZero: Bool
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - signum() - -
    -
    -
    -
    -
    -
    -

    Returns -1 if this value is negative and 1 if it’s positive; otherwise, 0.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func signum() -> BigInt
    - -
    -
    -
    -

    Return Value

    -

    The sign of this number, expressed as an integer of the same type.

    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - ~(_:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static prefix func ~(x: BigInt) -> BigInt
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - &(_:_:) - -
    -
    -
    -
    -
    -
    -

    Undocumented

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public struct BigInt: SignedInteger
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - |(_:_:) - -
    -
    -
    -
    -
    -
    -

    Undocumented

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public struct BigInt: SignedInteger
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - ^(_:_:) - -
    -
    -
    -
    -
    -
    -

    Undocumented

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public struct BigInt: SignedInteger
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - &=(_:_:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func &=(lhs: inout BigInt, rhs: BigInt)
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - |=(_:_:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func |=(lhs: inout BigInt, rhs: BigInt)
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - ^=(_:_:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func ^=(lhs: inout BigInt, rhs: BigInt)
    - -
    -
    - -
    -
    -
  • -
-
-
- -
    -
  • - -
    -
    -
    -
    -
    -

    Returns true iff this integer passes the strong probable prime test for the specified base.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func isStrongProbablePrime(_ base: BigInt) -> Bool
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - isPrime(rounds:) - -
    -
    -
    -
    -
    -
    -

    Returns true if this integer is probably prime. Returns false if this integer is definitely not prime.

    - -

    This function performs a probabilistic Miller-Rabin Primality Test, consisting of rounds iterations, -each calculating the strong probable prime test for a random base. The number of rounds is 10 by default, -but you may specify your own choice.

    - -

    To speed things up, the function checks if self is divisible by the first few prime numbers before -diving into (slower) Miller-Rabin testing.

    - -

    Also, when self is less than 82 bits wide, isPrime does a deterministic test that is guaranteed to -return a correct result.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func isPrime(rounds: Int = 10) -> Bool
    - -
    -
    - -
    -
    -
  • -
-
-
- -
-
-
    -
  • -
    - - - - Words - -
    -
    -
    -
    -
    -
    - - See more -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public struct Words: RandomAccessCollection
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - words - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var words: Words
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - init(words:) - -
    -
    -
    -
    -
    -
    -

    Undocumented

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public struct BigInt: SignedInteger
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - appendHashes(to:) - -
    -
    -
    -
    -
    -
    -

    Append this BigInt to the specified hasher.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func appendHashes(to hasher: inout SipHasher)
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - init(exactly:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init?<T: BinaryFloatingPoint>(exactly source: T)
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - init(_:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init<T: BinaryFloatingPoint>(_ source: T)
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - negate() - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public mutating func negate()
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - -(_:_:) - -
    -
    -
    -
    -
    -
    -

    Subtract b from a and return the result.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func -(a: BigInt, b: BigInt) -> BigInt
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - -=(_:_:) - -
    -
    -
    -
    -
    -
    -

    Subtract b from a in place.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func -=(a: inout BigInt, b: BigInt)
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • - -
    -
    -
    -
    -
    -

    Divide this integer by y and return the resulting quotient and remainder.

    -
    -

    Requires

    - y > 0 - -
    -
    -

    Complexity

    - O(count^2) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func quotientAndRemainder(dividingBy y: BigInt) -> (quotient: BigInt, remainder: BigInt)
    - -
    -
    -
    -

    Return Value

    -

    (quotient, remainder) where quotient = floor(self/y), remainder = self - quotient * y

    -
    - -
    -
    -
  • -
  • -
    - - - - /(_:_:) - -
    -
    -
    -
    -
    -
    -

    Divide a by b and return the quotient. Traps if b is zero.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func /(a: BigInt, b: BigInt) -> BigInt
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - %(_:_:) - -
    -
    -
    -
    -
    -
    -

    Divide a by b and return the remainder. The result has the same sign as a.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func %(a: BigInt, b: BigInt) -> BigInt
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - modulus(_:) - -
    -
    -
    -
    -
    -
    -

    Return the result of a mod b. The result is always a nonnegative integer that is less than the absolute value of b.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func modulus(_ mod: BigInt) -> BigInt
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - /=(_:_:) - -
    -
    -
    -
    -
    -
    -

    Divide a by b storing the quotient in a.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func /=(a: inout BigInt, b: BigInt)
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - %=(_:_:) - -
    -
    -
    -
    -
    -
    -

    Divide a by b storing the remainder in a.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func %=(a: inout BigInt, b: BigInt)
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - init() - -
    -
    -
    -
    -
    -
    -

    Undocumented

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public struct BigInt: SignedInteger
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - init(_:) - -
    -
    -
    -
    -
    -
    -

    Initializes a new signed big integer with the same value as the specified unsigned big integer.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init(_ integer: BigUInt)
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - init(_:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init<T>(_ source: T) where T : BinaryInteger
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - init(exactly:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init?<T>(exactly source: T) where T : BinaryInteger
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - init(clamping:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init<T>(clamping source: T) where T : BinaryInteger
    - -
    -
    - -
    -
    -
  • -
  • - -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init<T>(truncatingIfNeeded source: T) where T : BinaryInteger
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - init(integerLiteral:) - -
    -
    -
    -
    -
    -
    -

    Initialize a new big integer from an integer literal.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init(integerLiteral value: Int64)
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - ==(_:_:) - -
    -
    -
    -
    -
    -
    -

    Return true iff a is equal to b.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func ==(a: BigInt, b: BigInt) -> Bool
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - <(_:_:) - -
    -
    -
    -
    -
    -
    -

    Return true iff a is less than b.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func <(a: BigInt, b: BigInt) -> Bool
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - init(_:radix:) - -
    -
    -
    -
    -
    -
    -

    Initialize a big integer from an ASCII representation in a given radix. Numerals above 9 are represented by -letters from the English alphabet.

    -
    -

    Requires

    - radix > 1 && radix < 36 - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init?<S: StringProtocol>(_ text: S, radix: Int = 10)
    - -
    -
    -
    -

    Return Value

    -

    The integer represented by text, or nil if text contains a character that does not represent a numeral in radix.

    -
    - -
    -
    -
  • -
-
-
-
    -
  • - -
    -
    -
    -
    -
    -

    Initialize a new big integer from a Unicode scalar. -The scalar must represent a decimal digit.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init(unicodeScalarLiteral value: UnicodeScalar)
    - -
    -
    - -
    -
    -
  • -
  • - -
    -
    -
    -
    -
    -

    Initialize a new big integer from an extended grapheme cluster. -The cluster must consist of a decimal digit.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init(extendedGraphemeClusterLiteral value: String)
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - init(stringLiteral:) - -
    -
    -
    -
    -
    -
    -

    Initialize a new big integer from a decimal number represented by a string literal of arbitrary length. -The string must contain only decimal digits.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init(stringLiteral value: StringLiteralType)
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - description - -
    -
    -
    -
    -
    -
    -

    Return the decimal representation of this integer.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var description: String
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • - -
    -
    -
    -
    -
    -

    Return the playground quick look representation of this integer.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var customPlaygroundQuickLook: PlaygroundQuickLook
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - *(_:_:) - -
    -
    -
    -
    -
    -
    -

    Multiply a with b and return the result.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func *(a: BigInt, b: BigInt) -> BigInt
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - *=(_:_:) - -
    -
    -
    -
    -
    -
    -

    Multiply a with b in place.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func *=(a: inout BigInt, b: BigInt)
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - advanced(by:) - -
    -
    -
    -
    -
    -
    -

    Returns self + n.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func advanced(by n: Stride) -> BigInt
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - distance(to:) - -
    -
    -
    -
    -
    -
    -

    Returns other - self.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func distance(to other: BigInt) -> Stride
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - &<<(_:_:) - -
    -
    -
    -
    -
    -
    -

    Undocumented

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public struct BigInt: SignedInteger
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - &<<=(_:_:) - -
    -
    -
    -
    -
    -
    -

    Undocumented

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public struct BigInt: SignedInteger
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - &>>(_:_:) - -
    -
    -
    -
    -
    -
    -

    Undocumented

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public struct BigInt: SignedInteger
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - &>>=(_:_:) - -
    -
    -
    -
    -
    -
    -

    Undocumented

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public struct BigInt: SignedInteger
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - <<(_:_:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func <<<Other: BinaryInteger>(lhs: BigInt, rhs: Other) -> BigInt
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - <<=(_:_:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func <<=<Other: BinaryInteger>(lhs: inout BigInt, rhs: Other)
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - >>(_:_:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func >><Other: BinaryInteger>(lhs: BigInt, rhs: Other) -> BigInt
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - >>=(_:_:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func >>=<Other: BinaryInteger>(lhs: inout BigInt, rhs: Other)
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • - -
    -
    -
    -
    -
    -

    Returns the greatest common divisor of a and b.

    -
    -

    Complexity

    - O(count^2) where count = max(a.count, b.count) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func greatestCommonDivisor(with b: BigInt) -> BigInt
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - inverse(_:) - -
    -
    -
    -
    -
    -
    -

    Returns the multiplicative inverse of this integer in modulo modulus arithmetic, -or nil if there is no such number.

    -
    -

    Requires

    - modulus.magnitude > 1 - -
    -
    -

    Complexity

    - O(count^3) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func inverse(_ modulus: BigInt) -> BigInt?
    - -
    -
    -
    -

    Return Value

    -

    If gcd(self, modulus) == 1, the value returned is an integer a < modulus such that (a * self) % modulus == 1. If self and modulus aren’t coprime, the return value is nil.

    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - squareRoot() - -
    -
    -
    -
    -
    -
    -

    Returns the integer square root of a big integer; i.e., the largest integer whose square isn’t greater than value.

    -
    -

    Requires

    - self >= 0 - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func squareRoot() -> BigInt
    - -
    -
    -
    -

    Return Value

    -

    floor(sqrt(self))

    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - init(from:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init(from decoder: Decoder) throws
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - encode(to:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func encode(to encoder: Encoder) throws
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - power(_:) - -
    -
    -
    -
    -
    -
    -

    Returns this integer raised to the power exponent.

    - -

    This function calculates the result by successively squaring the base while halving the exponent.

    -
    -

    Note

    - This function can be unreasonably expensive for large exponents, which is why exponent is - a simple integer value. If you want to calculate big exponents, you’ll probably need to use - the modulo arithmetic variant. - -
    -
    -

    See also

    - BigUInt.power(_:, modulus:) - -
    -
    -

    Complexity

    - O((exponent * self.count)^log2(3)) or somesuch. The result may require a large amount of memory, too. - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func power(_ exponent: Int) -> BigInt
    - -
    -
    -
    -

    Return Value

    -

    1 if exponent == 0, otherwise self raised to exponent. (This implies that 0.power(0) == 1.)

    -
    - -
    -
    -
  • -
  • -
    - - - - power(_:modulus:) - -
    -
    -
    -
    -
    -
    -

    Returns the remainder of this integer raised to the power exponent in modulo arithmetic under modulus.

    - -

    Uses the right-to-left binary method.

    -
    -

    Complexity

    - O(exponent.count * modulus.count^log2(3)) or somesuch - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func power(_ exponent: BigInt, modulus: BigInt) -> BigInt
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - +(_:_:) - -
    -
    -
    -
    -
    -
    -

    Add a to b and return the result.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func +(a: BigInt, b: BigInt) -> BigInt
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - +=(_:_:) - -
    -
    -
    -
    -
    -
    -

    Add b to a in place.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func +=(a: inout BigInt, b: BigInt)
    - -
    -
    - -
    -
    -
  • -
-
-
-
- -
-
- - - - diff --git a/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/Structs/BigInt/Sign.html b/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/Structs/BigInt/Sign.html deleted file mode 100644 index 2db1db2de..000000000 --- a/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/Structs/BigInt/Sign.html +++ /dev/null @@ -1,167 +0,0 @@ - - - - Sign Enumeration Reference - - - - - - - - - - - - - - - - -
-

- - BigInt Docs - - (92% documented) -

- -

-

- -
-

- -

- - - View on GitHub - -

- -

- - - Install in Dash - -

-
- - - -
- -
- -
-
-

Sign

-

Undocumented

- -
-
- -
-
-
- -
-
- -
-
-
- -
-
- - - - diff --git a/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/Structs/BigInt/Words.html b/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/Structs/BigInt/Words.html deleted file mode 100644 index ba949c188..000000000 --- a/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/Structs/BigInt/Words.html +++ /dev/null @@ -1,240 +0,0 @@ - - - - Words Structure Reference - - - - - - - - - - - - - - - - -
-

- - BigInt Docs - - (92% documented) -

- -

-

- -
-

- -

- - - View on GitHub - -

- -

- - - Install in Dash - -

-
- - - -
- -
- -
-
-

Words

-
-
-
public struct Words: RandomAccessCollection
- -
-
- -
-
- -
-
-
-
    -
  • -
    - - - - count - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var count: Int
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - indices - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var indices: Indices
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - startIndex - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var startIndex: Int
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - endIndex - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var endIndex: Int
    - -
    -
    - -
    -
    -
  • -
-
-
-
- -
-
- - - - diff --git a/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/Structs/BigUInt.html b/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/Structs/BigUInt.html deleted file mode 100644 index 8c502f7c2..000000000 --- a/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/Structs/BigUInt.html +++ /dev/null @@ -1,3048 +0,0 @@ - - - - BigUInt Structure Reference - - - - - - - - - - - - - - - - -
-

- - BigInt Docs - - (92% documented) -

- -

-

- -
-

- -

- - - View on GitHub - -

- -

- - - Install in Dash - -

-
- - - -
- -
- -
-
-

BigUInt

-
-
-
public struct BigUInt: UnsignedInteger
- -
-
-

An arbitary precision unsigned integer type, also known as a big integer.

- -

Operations on big integers never overflow, but they may take a long time to execute. -The amount of memory (and address space) available is the only constraint to the magnitude of these numbers.

- -

This particular big integer type uses base-2^64 digits to represent integers; you can think of it as a wrapper -around Array<UInt64>. (In fact, BigUInt only uses an array if there are more than two digits.)

- -
-
- -
-
-
-
    -
  • -
    - - - - Word - -
    -
    -
    -
    -
    -
    -

    The type representing a digit in BigUInt‘s underlying number system.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public typealias Word = UInt
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - init() - -
    -
    -
    -
    -
    -
    -

    Initializes a new BigUInt with value 0.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init()
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - init(words:) - -
    -
    -
    -
    -
    -
    -

    Initializes a new BigUInt with the specified digits. The digits are ordered from least to most significant.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init(words: [Word])
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - ~(_:) - -
    -
    -
    -
    -
    -
    -

    Return the ones’ complement of a.

    -
    -

    Complexity

    - O(a.count) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static prefix func ~(a: BigUInt) -> BigUInt
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - |=(_:_:) - -
    -
    -
    -
    -
    -
    -

    Calculate the bitwise OR of a and b, and store the result in a.

    -
    -

    Complexity

    - O(max(a.count, b.count)) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func |= (a: inout BigUInt, b: BigUInt)
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - &=(_:_:) - -
    -
    -
    -
    -
    -
    -

    Calculate the bitwise AND of a and b and return the result.

    -
    -

    Complexity

    - O(max(a.count, b.count)) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func &= (a: inout BigUInt, b: BigUInt)
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - ^=(_:_:) - -
    -
    -
    -
    -
    -
    -

    Calculate the bitwise XOR of a and b and return the result.

    -
    -

    Complexity

    - O(max(a.count, b.count)) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func ^= (a: inout BigUInt, b: BigUInt)
    - -
    -
    - -
    -
    -
  • -
-
-
- -
    -
  • - -
    -
    -
    -
    -
    -

    Create a big integer consisting of width uniformly distributed random bits.

    -
    -

    Note

    - This function uses arc4random_buf to generate random bits. - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func randomInteger(withMaximumWidth width: Int) -> BigUInt
    - -
    -
    -
    -

    Return Value

    -

    A big integer less than 1 << width.

    -
    - -
    -
    -
  • -
  • - -
    -
    -
    -
    -
    -

    Create a big integer consisting of width-1 uniformly distributed random bits followed by a one bit.

    -
    -

    Note

    - This function uses arc4random_buf to generate random bits. - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func randomInteger(withExactWidth width: Int) -> BigUInt
    - -
    -
    -
    -

    Return Value

    -

    A random big integer whose width is width.

    -
    - -
    -
    -
  • -
  • - -
    -
    -
    -
    -
    -

    Create a uniformly distributed random integer that’s less than the specified limit.

    -
    -

    Note

    - This function uses arc4random_buf to generate random bits. - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func randomInteger(lessThan limit: BigUInt) -> BigUInt
    - -
    -
    -
    -

    Return Value

    -

    A random big integer that is less than limit.

    -
    - -
    -
    -
  • -
-
-
- -
    -
  • - -
    -
    -
    -
    -
    -

    Returns true iff this integer passes the strong probable prime test for the specified base.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func isStrongProbablePrime(_ base: BigUInt) -> Bool
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - isPrime(rounds:) - -
    -
    -
    -
    -
    -
    -

    Returns true if this integer is probably prime. Returns false if this integer is definitely not prime.

    - -

    This function performs a probabilistic Miller-Rabin Primality Test, consisting of rounds iterations, -each calculating the strong probable prime test for a random base. The number of rounds is 10 by default, -but you may specify your own choice.

    - -

    To speed things up, the function checks if self is divisible by the first few prime numbers before -diving into (slower) Miller-Rabin testing.

    - -

    Also, when self is less than 82 bits wide, isPrime does a deterministic test that is guaranteed to -return a correct result.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func isPrime(rounds: Int = 10) -> Bool
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - bitWidth - -
    -
    -
    -
    -
    -
    -

    The minimum number of bits required to represent this integer in binary.

    -
    -

    Complexity

    - O(1) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var bitWidth: Int
    - -
    -
    -
    -

    Return Value

    -

    floor(log2(2 * self + 1))

    -
    - -
    -
    -
  • -
  • -
    - - - - leadingZeroBitCount - -
    -
    -
    -
    -
    -
    -

    The number of leading zero bits in the binary representation of this integer in base 2^(Word.bitWidth). -This is useful when you need to normalize a BigUInt such that the top bit of its most significant word is 1.

    -
    -

    Note

    - 0 is considered to have zero leading zero bits. - -
    -
    -

    See also

    - width - -
    -
    -

    Complexity

    - O(1) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var leadingZeroBitCount: Int
    - -
    -
    -
    -

    Return Value

    -

    A value in 0...(Word.bitWidth - 1).

    -
    - -
    -
    -
  • -
  • -
    - - - - trailingZeroBitCount - -
    -
    -
    -
    -
    -
    -

    The number of trailing zero bits in the binary representation of this integer.

    -
    -

    Note

    - 0 is considered to have zero trailing zero bits. - -
    -
    -

    Complexity

    - O(count) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var trailingZeroBitCount: Int
    - -
    -
    -
    -

    Return Value

    -

    A value in 0...width.

    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - Words - -
    -
    -
    -
    -
    -
    - - See more -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public struct Words: RandomAccessCollection
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - words - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var words: Words
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - init(words:) - -
    -
    -
    -
    -
    -
    -

    Undocumented

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public struct BigUInt: UnsignedInteger
    - -
    -
    - -
    -
    -
  • -
-
-
- -
    -
  • -
    - - - - appendHashes(to:) - -
    -
    -
    -
    -
    -
    -

    Append this BigUInt to the specified hasher.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func appendHashes(to hasher: inout SipHasher)
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - init(exactly:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init?<T: BinaryFloatingPoint>(exactly source: T)
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - init(_:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init<T: BinaryFloatingPoint>(_ source: T)
    - -
    -
    - -
    -
    -
  • -
-
-
- -
    -
  • - -
    -
    -
    -
    -
    -

    Subtract other from this integer in place, and return a flag indicating if the operation caused an -arithmetic overflow. other is shifted shift digits to the left before being subtracted.

    -
    -

    Note

    - If the result indicates an overflow, then self becomes the twos’ complement of the absolute difference. - -
    -
    -

    Complexity

    - O(count) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public mutating func subtractReportingOverflow(_ b: BigUInt, shiftedBy shift: Int = 0) -> Bool
    - -
    -
    - -
    -
    -
  • -
  • - -
    -
    -
    -
    -
    -

    Subtract other from this integer, returning the difference and a flag indicating arithmetic overflow. -other is shifted shift digits to the left before being subtracted.

    -
    -

    Note

    - If overflow is true, then the result value is the twos’ complement of the absolute value of the difference. - -
    -
    -

    Complexity

    - O(count) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func subtractingReportingOverflow(_ other: BigUInt, shiftedBy shift: Int) -> (partialValue: BigUInt, overflow: Bool)
    - -
    -
    - -
    -
    -
  • -
  • - -
    -
    -
    -
    -
    -

    Subtracts other from self, returning the result and a flag indicating arithmetic overflow.

    -
    -

    Note

    - When the operation overflows, then partialValue is the twos’ complement of the absolute value of the difference. - -
    -
    -

    Complexity

    - O(count) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func subtractingReportingOverflow(_ other: BigUInt) -> (partialValue: BigUInt, overflow: Bool)
    - -
    -
    - -
    -
    -
  • -
  • - -
    -
    -
    -
    -
    -

    Subtract other from this integer in place. -other is shifted shift digits to the left before being subtracted.

    -
    -

    Requires

    - self >= other * 2^shift - -
    -
    -

    Complexity

    - O(count) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public mutating func subtract(_ other: BigUInt, shiftedBy shift: Int = 0)
    - -
    -
    - -
    -
    -
  • -
  • - -
    -
    -
    -
    -
    -

    Subtract b from this integer, and return the difference. -b is shifted shift digits to the left before being subtracted.

    -
    -

    Requires

    - self >= b * 2^shift - -
    -
    -

    Complexity

    - O(count) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func subtracting(_ other: BigUInt, shiftedBy shift: Int = 0) -> BigUInt
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - decrement(shiftedBy:) - -
    -
    -
    -
    -
    -
    -

    Decrement this integer by one.

    -
    -

    Requires

    - !isZero - -
    -
    -

    Complexity

    - O(count) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public mutating func decrement(shiftedBy shift: Int = 0)
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - -(_:_:) - -
    -
    -
    -
    -
    -
    -

    Subtract b from a and return the result.

    -
    -

    Requires

    - a >= b - -
    -
    -

    Complexity

    - O(a.count) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func -(a: BigUInt, b: BigUInt) -> BigUInt
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - -=(_:_:) - -
    -
    -
    -
    -
    -
    -

    Subtract b from a and store the result in a.

    -
    -

    Requires

    - a >= b - -
    -
    -

    Complexity

    - O(a.count) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func -=(a: inout BigUInt, b: BigUInt)
    - -
    -
    - -
    -
    -
  • -
-
-
- -
    -
  • - -
    -
    -
    -
    -
    -

    Divide this integer by y and return the resulting quotient and remainder.

    -
    -

    Requires

    - y > 0 - -
    -
    -

    Complexity

    - O(count^2) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func quotientAndRemainder(dividingBy y: BigUInt) -> (quotient: BigUInt, remainder: BigUInt)
    - -
    -
    -
    -

    Return Value

    -

    (quotient, remainder) where quotient = floor(self/y), remainder = self - quotient * y

    -
    - -
    -
    -
  • -
  • -
    - - - - /(_:_:) - -
    -
    -
    -
    -
    -
    -

    Divide x by y and return the quotient.

    -
    -

    Note

    - Use divided(by:) if you also need the remainder. - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func /(x: BigUInt, y: BigUInt) -> BigUInt
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - %(_:_:) - -
    -
    -
    -
    -
    -
    -

    Divide x by y and return the remainder.

    -
    -

    Note

    - Use divided(by:) if you also need the remainder. - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func %(x: BigUInt, y: BigUInt) -> BigUInt
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - /=(_:_:) - -
    -
    -
    -
    -
    -
    -

    Divide x by y and store the quotient in x.

    -
    -

    Note

    - Use divided(by:) if you also need the remainder. - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func /=(x: inout BigUInt, y: BigUInt)
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - %=(_:_:) - -
    -
    -
    -
    -
    -
    -

    Divide x by y and store the remainder in x.

    -
    -

    Note

    - Use divided(by:) if you also need the remainder. - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func %=(x: inout BigUInt, y: BigUInt)
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - init(exactly:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init?<T: BinaryInteger>(exactly source: T)
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - init(_:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init<T: BinaryInteger>(_ source: T)
    - -
    -
    - -
    -
    -
  • -
  • - -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init<T: BinaryInteger>(truncatingIfNeeded source: T)
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - init(clamping:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init<T: BinaryInteger>(clamping source: T)
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - init(integerLiteral:) - -
    -
    -
    -
    -
    -
    -

    Initialize a new big integer from an integer literal.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init(integerLiteral value: UInt64)
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - isSigned - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static var isSigned: Bool
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - signum() - -
    -
    -
    -
    -
    -
    -

    Returns -1 if this value is negative and 1 if it’s positive; otherwise, 0.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func signum() -> BigUInt
    - -
    -
    -
    -

    Return Value

    -

    The sign of this number, expressed as an integer of the same type.

    -
    - -
    -
    -
  • -
-
-
- -
    -
  • -
    - - - - subscript(_:) - -
    -
    -
    -
    -
    -
    -

    Get or set a digit at a given index.

    -
    -

    Note

    - Unlike a normal collection, it is OK for the index to be greater than or equal to endIndex. -The subscripting getter returns zero for indexes beyond the most significant digit. -Setting these extended digits automatically appends new elements to the underlying digit array. - -
    -
    -

    Requires

    - index >= 0 - -
    -
    -

    Complexity

    - The getter is O(1). The setter is O(1) if the conditions below are true; otherwise it’s O(count). - -
      -
    • The integer’s storage is not shared with another integer
    • -
    • The integer wasn’t created as a slice of another integer
    • -
    • index < count
    • -
    - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    subscript(_ index: Int) -> Word
    - -
    -
    - -
    -
    -
  • -
-
-
- -
    -
  • -
    - - - - compare(_:_:) - -
    -
    -
    -
    -
    -
    -

    Compare a to b and return an NSComparisonResult indicating their order.

    -
    -

    Complexity

    - O(count) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func compare(_ a: BigUInt, _ b: BigUInt) -> ComparisonResult
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - ==(_:_:) - -
    -
    -
    -
    -
    -
    -

    Return true iff a is equal to b.

    -
    -

    Complexity

    - O(count) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func ==(a: BigUInt, b: BigUInt) -> Bool
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - <(_:_:) - -
    -
    -
    -
    -
    -
    -

    Return true iff a is less than b.

    -
    -

    Complexity

    - O(count) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func <(a: BigUInt, b: BigUInt) -> Bool
    - -
    -
    - -
    -
    -
  • -
-
-
- -
    -
  • -
    - - - - init(_:radix:) - -
    -
    -
    -
    -
    -
    -

    Initialize a big integer from an ASCII representation in a given radix. Numerals above 9 are represented by -letters from the English alphabet.

    -
    -

    Requires

    - radix > 1 && radix < 36 - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init?(_ text: String, radix: Int = 10)
    - -
    -
    -
    -

    Return Value

    -

    The integer represented by text, or nil if text contains a character that does not represent a numeral in radix.

    -
    - -
    -
    -
  • -
  • -
    - - - - init(_:radix:) - -
    -
    -
    -
    -
    -
    -

    Undocumented

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public struct BigUInt: UnsignedInteger
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • - -
    -
    -
    -
    -
    -

    Initialize a new big integer from a Unicode scalar. -The scalar must represent a decimal digit.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init(unicodeScalarLiteral value: UnicodeScalar)
    - -
    -
    - -
    -
    -
  • -
  • - -
    -
    -
    -
    -
    -

    Initialize a new big integer from an extended grapheme cluster. -The cluster must consist of a decimal digit.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init(extendedGraphemeClusterLiteral value: String)
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - init(stringLiteral:) - -
    -
    -
    -
    -
    -
    -

    Initialize a new big integer from a decimal number represented by a string literal of arbitrary length. -The string must contain only decimal digits.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init(stringLiteral value: StringLiteralType)
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - description - -
    -
    -
    -
    -
    -
    -

    Return the decimal representation of this integer.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var description: String
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • - -
    -
    -
    -
    -
    -

    Return the playground quick look representation of this integer.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var customPlaygroundQuickLook: PlaygroundQuickLook
    - -
    -
    - -
    -
    -
  • -
-
-
- -
    -
  • -
    - - - - init(_:) - -
    -
    -
    -
    -
    -
    -

    Undocumented

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public struct BigUInt: UnsignedInteger
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - init(_:) - -
    -
    -
    -
    -
    -
    -

    Initializes an integer from the bits stored inside a piece of Data. -The data is assumed to be in network (big-endian) byte order.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init(_ data: Data)
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - serialize() - -
    -
    -
    -
    -
    -
    -

    Return a Data value that contains the base-256 representation of this integer, in network (big-endian) byte order.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func serialize() -> Data
    - -
    -
    - -
    -
    -
  • -
-
-
- -
    -
  • -
    - - - - multiply(byWord:) - -
    -
    -
    -
    -
    -
    -

    Multiply this big integer by a single word, and store the result in place of the original big integer.

    -
    -

    Complexity

    - O(count) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public mutating func multiply(byWord y: Word)
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - multiplied(byWord:) - -
    -
    -
    -
    -
    -
    -

    Multiply this big integer by a single Word, and return the result.

    -
    -

    Complexity

    - O(count) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func multiplied(byWord y: Word) -> BigUInt
    - -
    -
    - -
    -
    -
  • -
  • - -
    -
    -
    -
    -
    -

    Multiply x by y, and add the result to this integer, optionally shifted shift words to the left.

    -
    -

    Note

    - This is the fused multiply/shift/add operation; it is more efficient than doing the components -individually. (The fused operation doesn’t need to allocate space for temporary big integers.) - -
    -
    -

    Complexity

    - O(count) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public mutating func multiplyAndAdd(_ x: BigUInt, _ y: Word, shiftedBy shift: Int = 0)
    - -
    -
    -
    -

    Return Value

    -

    self is set to self + (x * y) << (shift * 2^Word.bitWidth)

    -
    - -
    -
    -
  • -
  • -
    - - - - multiplied(by:) - -
    -
    -
    -
    -
    -
    -

    Multiply this integer by y and return the result.

    -
    -

    Note

    - This uses the naive O(n^2) multiplication algorithm unless both arguments have more than -BigUInt.directMultiplicationLimit words. - -
    -
    -

    Complexity

    - O(n^log2(3)) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func multiplied(by y: BigUInt) -> BigUInt
    - -
    -
    - -
    -
    -
  • -
  • - -
    -
    -
    -
    -
    -

    Multiplication switches to an asymptotically better recursive algorithm when arguments have more words than this limit.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static var directMultiplicationLimit: Int = 1024
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - *(_:_:) - -
    -
    -
    -
    -
    -
    -

    Multiply a by b and return the result.

    -
    -

    Note

    - This uses the naive O(n^2) multiplication algorithm unless both arguments have more than -BigUInt.directMultiplicationLimit words. - -
    -
    -

    Complexity

    - O(n^log2(3)) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func *(x: BigUInt, y: BigUInt) -> BigUInt
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - *=(_:_:) - -
    -
    -
    -
    -
    -
    -

    Multiply a by b and store the result in a.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func *=(a: inout BigUInt, b: BigUInt)
    - -
    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - Stride - -
    -
    -
    -
    -
    -
    -

    A type that can represent the distance between two values ofa BigUInt.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public typealias Stride = BigInt
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - advanced(by:) - -
    -
    -
    -
    -
    -
    -

    Adds n to self and returns the result. Traps if the result would be less than zero.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func advanced(by n: BigInt) -> BigUInt
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - distance(to:) - -
    -
    -
    -
    -
    -
    -

    Returns the (potentially negative) difference between self and other as a BigInt. Never traps.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func distance(to other: BigUInt) -> BigInt
    - -
    -
    - -
    -
    -
  • -
-
-
- -
    -
  • -
    - - - - >>=(_:_:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func >>=<Other: BinaryInteger>(lhs: inout BigUInt, rhs: Other)
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - <<=(_:_:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func <<=<Other: BinaryInteger>(lhs: inout BigUInt, rhs: Other)
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - >>(_:_:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func >><Other: BinaryInteger>(lhs: BigUInt, rhs: Other) -> BigUInt
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - <<(_:_:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func <<<Other: BinaryInteger>(lhs: BigUInt, rhs: Other) -> BigUInt
    - -
    -
    - -
    -
    -
  • -
-
-
- -
    -
  • - -
    -
    -
    -
    -
    -

    Returns the greatest common divisor of self and b.

    -
    -

    Complexity

    - O(count^2) where count = max(self.count, b.count) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func greatestCommonDivisor(with b: BigUInt) -> BigUInt
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - inverse(_:) - -
    -
    -
    -
    -
    -
    -

    Returns the multiplicative inverse of this integer in modulo modulus arithmetic, -or nil if there is no such number.

    -
    -

    Requires

    - modulus > 1 - -
    -
    -

    Complexity

    - O(count^3) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func inverse(_ modulus: BigUInt) -> BigUInt?
    - -
    -
    -
    -

    Return Value

    -

    If gcd(self, modulus) == 1, the value returned is an integer a < modulus such that (a * self) % modulus == 1. If self and modulus aren’t coprime, the return value is nil.

    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - squareRoot() - -
    -
    -
    -
    -
    -
    -

    Returns the integer square root of a big integer; i.e., the largest integer whose square isn’t greater than value.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func squareRoot() -> BigUInt
    - -
    -
    -
    -

    Return Value

    -

    floor(sqrt(self))

    -
    - -
    -
    -
  • -
-
-
-
    -
  • -
    - - - - init(from:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public init(from decoder: Decoder) throws
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - encode(to:) - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func encode(to encoder: Encoder) throws
    - -
    -
    - -
    -
    -
  • -
-
-
- -
    -
  • -
    - - - - power(_:) - -
    -
    -
    -
    -
    -
    -

    Returns this integer raised to the power exponent.

    - -

    This function calculates the result by successively squaring the base while halving the exponent.

    -
    -

    Note

    - This function can be unreasonably expensive for large exponents, which is why exponent is - a simple integer value. If you want to calculate big exponents, you’ll probably need to use - the modulo arithmetic variant. - -
    -
    -

    See also

    - BigUInt.power(_:, modulus:) - -
    -
    -

    Complexity

    - O((exponent * self.count)^log2(3)) or somesuch. The result may require a large amount of memory, too. - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func power(_ exponent: Int) -> BigUInt
    - -
    -
    -
    -

    Return Value

    -

    1 if exponent == 0, otherwise self raised to exponent. (This implies that 0.power(0) == 1.)

    -
    - -
    -
    -
  • -
  • -
    - - - - power(_:modulus:) - -
    -
    -
    -
    -
    -
    -

    Returns the remainder of this integer raised to the power exponent in modulo arithmetic under modulus.

    - -

    Uses the right-to-left binary method.

    -
    -

    Complexity

    - O(exponent.count * modulus.count^log2(3)) or somesuch - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func power(_ exponent: BigUInt, modulus: BigUInt) -> BigUInt
    - -
    -
    - -
    -
    -
  • -
-
-
- -
    -
  • -
    - - - - +(_:_:) - -
    -
    -
    -
    -
    -
    -

    Add a and b together and return the result.

    -
    -

    Complexity

    - O(max(a.count, b.count)) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func +(a: BigUInt, b: BigUInt) -> BigUInt
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - +=(_:_:) - -
    -
    -
    -
    -
    -
    -

    Add a and b together, and store the sum in a.

    -
    -

    Complexity

    - O(max(a.count, b.count)) - -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func +=(a: inout BigUInt, b: BigUInt)
    - -
    -
    - -
    -
    -
  • -
-
-
-
- -
-
- - - - diff --git a/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/Structs/BigUInt/Words.html b/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/Structs/BigUInt/Words.html deleted file mode 100644 index b0dda68e0..000000000 --- a/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/Structs/BigUInt/Words.html +++ /dev/null @@ -1,182 +0,0 @@ - - - - Words Structure Reference - - - - - - - - - - - - - - - - -
-

- - BigInt Docs - - (92% documented) -

- -

-

- -
-

- -

- - - View on GitHub - -

- -

- - - Install in Dash - -

-
- - - -
- -
- -
-
-

Words

-
-
-
public struct Words: RandomAccessCollection
- -
-
- -
-
- -
-
-
-
    -
  • -
    - - - - startIndex - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var startIndex: Int
    - -
    -
    - -
    -
    -
  • -
  • -
    - - - - endIndex - -
    -
    -
    -
    -
    -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var endIndex: Int
    - -
    -
    - -
    -
    -
  • -
-
-
-
- -
-
- - - - diff --git a/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/css/highlight.css b/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/css/highlight.css deleted file mode 100644 index d0db0e13b..000000000 --- a/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/css/highlight.css +++ /dev/null @@ -1,200 +0,0 @@ -/* Credit to https://gist.github.com/wataru420/2048287 */ -.highlight { - /* Comment */ - /* Error */ - /* Keyword */ - /* Operator */ - /* Comment.Multiline */ - /* Comment.Preproc */ - /* Comment.Single */ - /* Comment.Special */ - /* Generic.Deleted */ - /* Generic.Deleted.Specific */ - /* Generic.Emph */ - /* Generic.Error */ - /* Generic.Heading */ - /* Generic.Inserted */ - /* Generic.Inserted.Specific */ - /* Generic.Output */ - /* Generic.Prompt */ - /* Generic.Strong */ - /* Generic.Subheading */ - /* Generic.Traceback */ - /* Keyword.Constant */ - /* Keyword.Declaration */ - /* Keyword.Pseudo */ - /* Keyword.Reserved */ - /* Keyword.Type */ - /* Literal.Number */ - /* Literal.String */ - /* Name.Attribute */ - /* Name.Builtin */ - /* Name.Class */ - /* Name.Constant */ - /* Name.Entity */ - /* Name.Exception */ - /* Name.Function */ - /* Name.Namespace */ - /* Name.Tag */ - /* Name.Variable */ - /* Operator.Word */ - /* Text.Whitespace */ - /* Literal.Number.Float */ - /* Literal.Number.Hex */ - /* Literal.Number.Integer */ - /* Literal.Number.Oct */ - /* Literal.String.Backtick */ - /* Literal.String.Char */ - /* Literal.String.Doc */ - /* Literal.String.Double */ - /* Literal.String.Escape */ - /* Literal.String.Heredoc */ - /* Literal.String.Interpol */ - /* Literal.String.Other */ - /* Literal.String.Regex */ - /* Literal.String.Single */ - /* Literal.String.Symbol */ - /* Name.Builtin.Pseudo */ - /* Name.Variable.Class */ - /* Name.Variable.Global */ - /* Name.Variable.Instance */ - /* Literal.Number.Integer.Long */ } - .highlight .c { - color: #999988; - font-style: italic; } - .highlight .err { - color: #a61717; - background-color: #e3d2d2; } - .highlight .k { - color: #000000; - font-weight: bold; } - .highlight .o { - color: #000000; - font-weight: bold; } - .highlight .cm { - color: #999988; - font-style: italic; } - .highlight .cp { - color: #999999; - font-weight: bold; } - .highlight .c1 { - color: #999988; - font-style: italic; } - .highlight .cs { - color: #999999; - font-weight: bold; - font-style: italic; } - .highlight .gd { - color: #000000; - background-color: #ffdddd; } - .highlight .gd .x { - color: #000000; - background-color: #ffaaaa; } - .highlight .ge { - color: #000000; - font-style: italic; } - .highlight .gr { - color: #aa0000; } - .highlight .gh { - color: #999999; } - .highlight .gi { - color: #000000; - background-color: #ddffdd; } - .highlight .gi .x { - color: #000000; - background-color: #aaffaa; } - .highlight .go { - color: #888888; } - .highlight .gp { - color: #555555; } - .highlight .gs { - font-weight: bold; } - .highlight .gu { - color: #aaaaaa; } - .highlight .gt { - color: #aa0000; } - .highlight .kc { - color: #000000; - font-weight: bold; } - .highlight .kd { - color: #000000; - font-weight: bold; } - .highlight .kp { - color: #000000; - font-weight: bold; } - .highlight .kr { - color: #000000; - font-weight: bold; } - .highlight .kt { - color: #445588; } - .highlight .m { - color: #009999; } - .highlight .s { - color: #d14; } - .highlight .na { - color: #008080; } - .highlight .nb { - color: #0086B3; } - .highlight .nc { - color: #445588; - font-weight: bold; } - .highlight .no { - color: #008080; } - .highlight .ni { - color: #800080; } - .highlight .ne { - color: #990000; - font-weight: bold; } - .highlight .nf { - color: #990000; } - .highlight .nn { - color: #555555; } - .highlight .nt { - color: #000080; } - .highlight .nv { - color: #008080; } - .highlight .ow { - color: #000000; - font-weight: bold; } - .highlight .w { - color: #bbbbbb; } - .highlight .mf { - color: #009999; } - .highlight .mh { - color: #009999; } - .highlight .mi { - color: #009999; } - .highlight .mo { - color: #009999; } - .highlight .sb { - color: #d14; } - .highlight .sc { - color: #d14; } - .highlight .sd { - color: #d14; } - .highlight .s2 { - color: #d14; } - .highlight .se { - color: #d14; } - .highlight .sh { - color: #d14; } - .highlight .si { - color: #d14; } - .highlight .sx { - color: #d14; } - .highlight .sr { - color: #009926; } - .highlight .s1 { - color: #d14; } - .highlight .ss { - color: #990073; } - .highlight .bp { - color: #999999; } - .highlight .vc { - color: #008080; } - .highlight .vg { - color: #008080; } - .highlight .vi { - color: #008080; } - .highlight .il { - color: #009999; } diff --git a/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/css/jazzy.css b/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/css/jazzy.css deleted file mode 100644 index c83db5bfc..000000000 --- a/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/css/jazzy.css +++ /dev/null @@ -1,368 +0,0 @@ -*, *:before, *:after { - box-sizing: inherit; } - -body { - margin: 0; - background: #fff; - color: #333; - font: 16px/1.7 "Helvetica Neue", Helvetica, Arial, sans-serif; - letter-spacing: .2px; - -webkit-font-smoothing: antialiased; - box-sizing: border-box; } - -h1 { - font-size: 2rem; - font-weight: 700; - margin: 1.275em 0 0.6em; } - -h2 { - font-size: 1.75rem; - font-weight: 700; - margin: 1.275em 0 0.3em; } - -h3 { - font-size: 1.5rem; - font-weight: 700; - margin: 1em 0 0.3em; } - -h4 { - font-size: 1.25rem; - font-weight: 700; - margin: 1.275em 0 0.85em; } - -h5 { - font-size: 1rem; - font-weight: 700; - margin: 1.275em 0 0.85em; } - -h6 { - font-size: 1rem; - font-weight: 700; - margin: 1.275em 0 0.85em; - color: #777; } - -p { - margin: 0 0 1em; } - -ul, ol { - padding: 0 0 0 2em; - margin: 0 0 0.85em; } - -blockquote { - margin: 0 0 0.85em; - padding: 0 15px; - color: #858585; - border-left: 4px solid #e5e5e5; } - -img { - max-width: 100%; } - -a { - color: #4183c4; - text-decoration: none; } - a:hover, a:focus { - outline: 0; - text-decoration: underline; } - -table { - background: #fff; - width: 100%; - border-collapse: collapse; - border-spacing: 0; - overflow: auto; - margin: 0 0 0.85em; } - -tr:nth-child(2n) { - background-color: #fbfbfb; } - -th, td { - padding: 6px 13px; - border: 1px solid #ddd; } - -pre { - margin: 0 0 1.275em; - padding: .85em 1em; - overflow: auto; - background: #f7f7f7; - font-size: .85em; - font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; } - -code { - font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; } - -p > code, li > code { - background: #f7f7f7; - padding: .2em; } - p > code:before, p > code:after, li > code:before, li > code:after { - letter-spacing: -.2em; - content: "\00a0"; } - -pre code { - padding: 0; - white-space: pre; } - -.content-wrapper { - display: flex; - flex-direction: column; } - @media (min-width: 768px) { - .content-wrapper { - flex-direction: row; } } - -.header { - display: flex; - padding: 8px; - font-size: 0.875em; - background: #444; - color: #999; } - -.header-col { - margin: 0; - padding: 0 8px; } - -.header-col--primary { - flex: 1; } - -.header-link { - color: #fff; } - -.header-icon { - padding-right: 6px; - vertical-align: -4px; - height: 16px; } - -.breadcrumbs { - font-size: 0.875em; - padding: 8px 16px; - margin: 0; - background: #fbfbfb; - border-bottom: 1px solid #ddd; } - -.carat { - height: 10px; - margin: 0 5px; } - -.navigation { - order: 2; } - @media (min-width: 768px) { - .navigation { - order: 1; - width: 25%; - max-width: 300px; - padding-bottom: 64px; - overflow: hidden; - word-wrap: normal; - background: #fbfbfb; - border-right: 1px solid #ddd; } } - -.nav-groups { - list-style-type: none; - padding-left: 0; } - -.nav-group-name { - border-bottom: 1px solid #ddd; - padding: 8px 0 8px 16px; } - -.nav-group-name-link { - color: #333; } - -.nav-group-tasks { - margin: 8px 0; - padding: 0 0 0 8px; } - -.nav-group-task { - font-size: 1em; - list-style-type: none; - white-space: nowrap; } - -.nav-group-task-link { - color: #808080; } - -.main-content { - order: 1; } - @media (min-width: 768px) { - .main-content { - order: 2; - flex: 1; - padding-bottom: 60px; } } - -.section { - padding: 0 32px; - border-bottom: 1px solid #ddd; } - -.section-content { - max-width: 834px; - margin: 0 auto; - padding: 16px 0; } - -.section-name { - color: #666; - display: block; } - -.declaration .highlight { - overflow-x: initial; - padding: 8px 0; - margin: 0; - background-color: transparent; - border: none; } - -.task-group-section { - border-top: 1px solid #ddd; } - -.task-group { - padding-top: 0px; } - -.task-name-container a[name]:before { - content: ""; - display: block; } - -.item-container { - padding: 0; } - -.item { - padding-top: 8px; - width: 100%; - list-style-type: none; } - .item a[name]:before { - content: ""; - display: block; } - .item .token { - padding-left: 3px; - margin-left: 0px; - font-size: 1rem; } - .item .declaration-note { - font-size: .85em; - color: #808080; - font-style: italic; } - -.pointer-container { - border-bottom: 1px solid #ddd; - left: -23px; - padding-bottom: 13px; - position: relative; - width: 110%; } - -.pointer { - left: 21px; - top: 7px; - display: block; - position: absolute; - width: 12px; - height: 12px; - border-left: 1px solid #ddd; - border-top: 1px solid #ddd; - background: #fff; - transform: rotate(45deg); } - -.height-container { - display: none; - position: relative; - width: 100%; - overflow: hidden; } - .height-container .section { - background: #fff; - border: 1px solid #ddd; - border-top-width: 0; - padding-top: 10px; - padding-bottom: 5px; - padding: 8px 16px; } - -.aside, .language { - padding: 6px 12px; - margin: 12px 0; - border-left: 5px solid #dddddd; - overflow-y: hidden; } - .aside .aside-title, .language .aside-title { - font-size: 9px; - letter-spacing: 2px; - text-transform: uppercase; - padding-bottom: 0; - margin: 0; - color: #aaa; - -webkit-user-select: none; } - .aside p:last-child, .language p:last-child { - margin-bottom: 0; } - -.language { - border-left: 5px solid #cde9f4; } - .language .aside-title { - color: #4183c4; } - -.aside-warning { - border-left: 5px solid #ff6666; } - .aside-warning .aside-title { - color: #ff0000; } - -.graybox { - border-collapse: collapse; - width: 100%; } - .graybox p { - margin: 0; - word-break: break-word; - min-width: 50px; } - .graybox td { - border: 1px solid #ddd; - padding: 5px 25px 5px 10px; - vertical-align: middle; } - .graybox tr td:first-of-type { - text-align: right; - padding: 7px; - vertical-align: top; - word-break: normal; - width: 40px; } - -.slightly-smaller { - font-size: 0.9em; } - -.footer { - padding: 8px 16px; - background: #444; - color: #ddd; - font-size: 0.8em; } - .footer p { - margin: 8px 0; } - .footer a { - color: #fff; } - -html.dash .header, html.dash .breadcrumbs, html.dash .navigation { - display: none; } -html.dash .height-container { - display: block; } - -form[role=search] input { - font: 16px/1.7 "Helvetica Neue", Helvetica, Arial, sans-serif; - font-size: 14px; - line-height: 24px; - padding: 0 10px; - margin: 0; - border: none; - border-radius: 1em; } - .loading form[role=search] input { - background: white url(../img/spinner.gif) center right 4px no-repeat; } -form[role=search] .tt-menu { - margin: 0; - min-width: 300px; - background: #fbfbfb; - color: #333; - border: 1px solid #ddd; } -form[role=search] .tt-highlight { - font-weight: bold; } -form[role=search] .tt-suggestion { - font: 16px/1.7 "Helvetica Neue", Helvetica, Arial, sans-serif; - padding: 0 8px; } - form[role=search] .tt-suggestion span { - display: table-cell; - white-space: nowrap; } - form[role=search] .tt-suggestion .doc-parent-name { - width: 100%; - text-align: right; - font-weight: normal; - font-size: 0.9em; - padding-left: 16px; } -form[role=search] .tt-suggestion:hover, -form[role=search] .tt-suggestion.tt-cursor { - cursor: pointer; - background-color: #4183c4; - color: #fff; } -form[role=search] .tt-suggestion:hover .doc-parent-name, -form[role=search] .tt-suggestion.tt-cursor .doc-parent-name { - color: #fff; } diff --git a/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/img/carat.png b/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/img/carat.png deleted file mode 100755 index 29d2f7fd4..000000000 Binary files a/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/img/carat.png and /dev/null differ diff --git a/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/img/dash.png b/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/img/dash.png deleted file mode 100755 index 6f694c7a0..000000000 Binary files a/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/img/dash.png and /dev/null differ diff --git a/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/img/gh.png b/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/img/gh.png deleted file mode 100755 index 628da97c7..000000000 Binary files a/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/img/gh.png and /dev/null differ diff --git a/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/img/spinner.gif b/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/img/spinner.gif deleted file mode 100644 index e3038d0a4..000000000 Binary files a/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/img/spinner.gif and /dev/null differ diff --git a/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/index.html b/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/index.html deleted file mode 100644 index 15361d37f..000000000 --- a/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/index.html +++ /dev/null @@ -1,478 +0,0 @@ - - - - BigInt Reference - - - - - - - - - - - - - - - -
-

- - BigInt Docs - - (92% documented) -

- -

-

- -
-

- -

- - - View on GitHub - -

- -

- - - Install in Dash - -

-
- - - -
- -
- -
-
- -

BigInt

- - - -

Swift 3 -License -Platform

- -

Build Status -Code Coverage -Carthage compatible -Version

-

Overview

- -

This repository provides integer types of arbitrary width implemented -in 100% pure Swift. The underlying representation is in base 2^64, using Array<UInt64>.

- -

This module is handy when you need an integer type that’s wider than UIntMax, but -you don’t want to add The GNU Multiple Precision Arithmetic Library -as a dependency.

- -

Two big integer types are included: BigUInt and BigInt, -the latter being the signed variant. -Both of these are Swift structs with copy-on-write value semantics, and they can be used much -like any other integer type.

- -

The library provides implementations for some of the most frequently useful functions on -big integers, including

- - - -

The implementations are intended to be reasonably efficient, but they are unlikely to be -competitive with GMP at all, even when I happened to implement an algorithm with same asymptotic -behavior as GMP. (I haven’t performed a comparison benchmark, though.)

- -

The library has 100% unit test coverage. Sadly this does not imply that there are no bugs -in it.

-

API Documentation

- -

Generated API docs are available at http://attaswift.github.io/BigInt/.

-

License

- -

BigInt can be used, distributed and modified under the MIT license.

-

Requirements and Integration

- -

BigInt 3.0.0 requires Swift 4. (The last version with support for Swift 3.x was BigInt 2.1.0. -The last version with support for Swift 2 was BigInt 1.3.0.)

- -

BigInt deploys to macOS 10.10, iOS 9, watchOS 2 and tvOS 9. -It has been tested on the latest OS releases only—however, as the module uses very few platform-provided APIs, -there should be very few issues with earlier versions.

- -

BigInt uses no APIs specific to Apple platforms except for arc4random_buf in BigUInt Random.swift, so -it should be easy to port it to other operating systems.

- -

Setup instructions:

- -
    -
  • Swift Package Manager: -Although the Package Manager is still in its infancy, BigInt provides experimental support for it. -Add this to the dependency section of your Package.swift manifest:

    -
    .Package(url: "https://github.com/attaswift/BigInt.git", from: "3.0.0")
    -
  • -
  • CocoaPods: Put this in your Podfile:

    -
    pod 'BigInt', '~> 3.0'
    -
  • -
  • Carthage: Put this in your Cartfile:

    -
    github "attaswift/BigInt" ~> 3.0
    -
  • -
-

Implementation notes

- -

BigUInt is a MutableCollectionType of its 64-bit digits, with the least significant -digit at index 0. As a convenience, BigUInt allows you to subscript it with indexes at -or above its count. The subscript operator returns 0 for out-of-bound gets and -automatically extends the array on out-of-bound sets. This makes memory management simpler.

- -

BigInt is just a tiny wrapper around a BigUInt absolute value and a -sign bit, both of which are accessible as public read-write properties.

-

Full-width multiplication and division primitives

- -

I haven’t found (64,64)->128 multiplication or (128,64)->64 division operations -in Swift, so the module has generic implementations for them in terms of the standard -single-width * and / operators. I suspect there are LLVM intrinsics for full-width -arithmetics that are probably accessible somehow, though. (Let me know if you know how!)

- -

This sounds slow, but 64-bit digits are -still considerably faster than 32-bit, even though the latter can use direct 64-bit arithmetic to -implement these primitives.

-

Why is there no generic BigInt<Digit> type?

- -

The types provided by BigInt are not parametric—this is very much intentional, as -Swift generics cost us dearly at runtime in this use case. In every approach I tried, -making arbitrary-precision arithmetic operations work with a generic Digit type parameter -resulted in code that was literally ten times slower. If you can make the algorithms generic -without such a huge performance hit, please enlighten me!

- -

This is an area that I plan to investigate more, as it would be useful to have generic -implementations for arbitrary-width arithmetic operations. (Polynomial division and decimal bases -are two examples.) The library already implements double-digit multiplication and division as -extension methods on a protocol with an associated type requirement; this has not measurably affected -performance. Unfortunately, the same is not true for BigUInt‘s methods.

- -

Of course, as a last resort, we could just duplicate the code to create a separate -generic variant that was slower but more flexible.

-

Calculation Samples

-

Obligatory Factorial Demo

- -

It is easy to use BigInt to calculate the factorial function for any integer:

-
import BigInt
-
-func factorial(_ n: Int) -> BigInt {
-    return (1 ... n).map { BigInt($0) }.reduce(BigInt(1), *)
-}
-
-print(factorial(10))
-==> 362880
-
-print(factorial(100))
-==> 93326215443944152681699238856266700490715968264381621468592963895217599993229915
-    6089414639761565182862536979208272237582511852109168640000000000000000000000
-
-print(factorial(1000))
-==> 40238726007709377354370243392300398571937486421071463254379991042993851239862902
-    05920442084869694048004799886101971960586316668729948085589013238296699445909974
-    24504087073759918823627727188732519779505950995276120874975462497043601418278094
-    64649629105639388743788648733711918104582578364784997701247663288983595573543251
-    31853239584630755574091142624174743493475534286465766116677973966688202912073791
-    43853719588249808126867838374559731746136085379534524221586593201928090878297308
-    43139284440328123155861103697680135730421616874760967587134831202547858932076716
-    91324484262361314125087802080002616831510273418279777047846358681701643650241536
-    91398281264810213092761244896359928705114964975419909342221566832572080821333186
-    11681155361583654698404670897560290095053761647584772842188967964624494516076535
-    34081989013854424879849599533191017233555566021394503997362807501378376153071277
-    61926849034352625200015888535147331611702103968175921510907788019393178114194545
-    25722386554146106289218796022383897147608850627686296714667469756291123408243920
-    81601537808898939645182632436716167621791689097799119037540312746222899880051954
-    44414282012187361745992642956581746628302955570299024324153181617210465832036786
-    90611726015878352075151628422554026517048330422614397428693306169089796848259012
-    54583271682264580665267699586526822728070757813918581788896522081643483448259932
-    66043367660176999612831860788386150279465955131156552036093988180612138558600301
-    43569452722420634463179746059468257310379008402443243846565724501440282188525247
-    09351906209290231364932734975655139587205596542287497740114133469627154228458623
-    77387538230483865688976461927383814900140767310446640259899490222221765904339901
-    88601856652648506179970235619389701786004081188972991831102117122984590164192106
-    88843871218556461249607987229085192968193723886426148396573822911231250241866493
-    53143970137428531926649875337218940694281434118520158014123344828015051399694290
-    15348307764456909907315243327828826986460278986432113908350621709500259738986355
-    42771967428222487575867657523442202075736305694988250879689281627538488633969099
-    59826280956121450994871701244516461260379029309120889086942028510640182154399457
-    15680594187274899809425474217358240106367740459574178516082923013535808184009699
-    63725242305608559037006242712434169090041536901059339838357779394109700277534720
-    00000000000000000000000000000000000000000000000000000000000000000000000000000000
-    00000000000000000000000000000000000000000000000000000000000000000000000000000000
-    00000000000000000000000000000000000000000000000000000000000000000000000000000000
-    00000
-
- -

Well, I guess that’s all right, but it’s not very interesting. Let’s try something more useful.

-

RSA Cryptography

- -

The BigInt module provides all necessary parts to implement an (overly) -simple RSA cryptography system.

- -

Let’s start with a simple function that generates a random n-bit prime. The module -includes a function to generate random integers of a specific size, and also an -isPrime method that performs the Miller–Rabin primality test. These are all we need:

-
func generatePrime(_ width: Int) -> BigUInt {
-    while true {
-        var random = BigUInt.randomInteger(withExactWidth: width)
-        random |= BigUInt(1)
-        if random.isPrime() {
-            return random
-        }
-    }
-}
-
-let p = generatePrime(1024)
-==> 13308187650642192396256419911012544845370493728424936791561478318443071617242872
-    81980956747087187419914435169914161116601678883358611076800743580556055714173922
-    08406194264346635072293912609713085260354070700055888678514690878149253177960273
-    775659537560220378850112471985434373425534121373466492101182463962031
-
-let q = generatePrime(1024)
-==> 17072954422657145489547308812333368925007949054501204983863958355897172093173783
-    10108226596943999553784252564650624766276133157586733504784616138305701168410157
-    80784336308507083874651158029602582993233111593356512531869546706885170044355115
-    669728424124141763799008880327106952436883614887277350838425336156327
-
- -

Cool! Now that we have two large primes, we can produce an RSA public/private keypair -out of them.

-
typealias Key = (modulus: BigUInt, exponent: BigUInt)
-
-let n = p * q
-==> 22721008120758282530010953362926306641542233757318103044313144976976529789946696
-    15454966720907712515917481418981591379647635391260569349099666410127279690367978
-    81184375533755888994370640857883754985364288413796100527262763202679037134021810
-    57933883525572232242690805678883227791774442041516929419640051653934584376704034
-    63953169772816907280591934423237977258358097846511079947337857778137177570668391
-    57455417707100275487770399281417352829897118140972240757708561027087217205975220
-    02207275447810167397968435583004676293892340103729490987263776871467057582629588
-    916498579594964478080508868267360515953225283461208420137
-
-let e: BigUInt = 65537
-let phi = (p - 1) * (q - 1)
-let d = e.inverse(phi)!     // d * e % phi == 1
-==> 13964664343869014759736350480776837992604500903989703383202366291905558996277719
-    77822086142456362972689566985925179681282432115598451765899180050962461295573831
-    37069237934291884106584820998146965085531433195106686745474222222620986858696591
-    69836532468835154412554521152103642453158895363417640676611704542784576974374954
-    45789456921660619938185093118762690200980720312508614337759620606992462563490422
-    76669559556568917533268479190948959560397579572761529852891246283539604545691244
-    89999692877158676643042118662613875863504016129837099223040687512684532694527109
-    80742873307409704484365002175294665608486688146261327793
-
-let publicKey: Key = (n, e)
-let privateKey: Key = (n, d)
-
- -

In RSA, modular exponentiation is used to encrypt (and decrypt) messages.

-
func encrypt(_ message: BigUInt, key: Key) -> BigUInt {
-    return message.power(key.exponent, modulus: key.modulus)
-}
-
- -

Let’s try out our new keypair by converting a string into UTF-8, interpreting -the resulting binary representation as a big integer, and encrypting it with the -public key. BigUInt has an initializer that takes an NSData, so this is pretty -easy to do:

-
let secret: BigUInt = BigUInt("Arbitrary precision arithmetic is fun!".dataUsingEncoding(NSUTF8StringEncoding)!)
-==> 83323446846105976078466731524728681905293067701804838925389198929123912971229457
-    68818568737
-
-let cyphertext = encrypt(secret, key: publicKey)
-==> 95186982543485985200666516508066093880038842892337880561554910904277290917831453
-    54854954722744805432145474047391353716305176389470779020645959135298322520888633
-    61674945129099575943384767330342554525120384485469428048962027149169876127890306
-    77028183904699491962050888974524603226290836984166164759586952419343589385279641
-    47999991283152843977988979846238236160274201261075188190509539751990119132013021
-    74866638595734222867005089157198503204192264814750832072844208520394603054901706
-    06024394731371973402595826456435944968439153664617188570808940022471990638468783
-    49208193955207336172861151720299024935127021719852700882
-
- -

Well, it looks encrypted all right, but can we get the original message back? -In theory, encrypting the cyphertext with the private key returns the original message. -Let’s see:

-
let plaintext = encrypt(cyphertext, key: privateKey)
-==> 83323446846105976078466731524728681905293067701804838925389198929123912971229457
-    68818568737
-
-let received = String(data: plaintext.serialize(), encoding: NSUTF8StringEncoding)
-==> "Arbitrary precision arithmetic is fun!"
-
- -

Yay! This is truly terrific, but please don’t use this example code in an actual -cryptography system. RSA has lots of subtle (and some not so subtle) complications -that we ignored to keep this example short.

-

Calculating the Digits of π

- -

Another fun activity to try with BigInts is to generate the digits of π. -Let’s try implementing Jeremy Gibbon’s spigot algorithm. -This is a rather slow algorithm as π-generators go, but it makes up for it with its grooviness -factor: it’s remarkably short, it only uses (big) integer arithmetic, and every iteration -produces a single new digit in the base-10 representation of π. This naturally leads to an -implementation as an infinite GeneratorType:

-
func digitsOfPi() -> AnyGenerator<Int> {
-    var q: BigUInt = 1
-    var r: BigUInt = 180
-    var t: BigUInt = 60
-    var i: UInt64 = 2 // Does not overflow until digit #826_566_842
-    return AnyIterator {
-        let u: UInt64 = 3 * (3 * i + 1) * (3 * i + 2)
-        let y = (q.multiplied(byDigit: 27 * i - 12) + 5 * r) / (5 * t)
-        (q, r, t) = (
-            10 * q.multiplied(byDigit: i * (2 * i - 1)),
-            10 * (q.multiplied(byDigit: 5 * i - 2) + r - y * t).multiplied(byDigit: u),
-            t.multiplied(byDigit: u))
-        i += 1
-        return Int(y[0])
-    }
-}
-
- -

Well, that was surprisingly easy. But does it work? Of course it does!

-
var digits = "π ≈ "
-var count = 0
-for digit in digitsOfPi() {
-    assert(digit < 10)
-    digits += String(digit)
-    count += 1
-    if count == 1 { digits += "." }
-    if count == 1000 { break }
-}
-
-digits
-==> π ≈ 3.14159265358979323846264338327950288419716939937510582097494459230781640628
-    62089986280348253421170679821480865132823066470938446095505822317253594081284811
-    17450284102701938521105559644622948954930381964428810975665933446128475648233786
-    78316527120190914564856692346034861045432664821339360726024914127372458700660631
-    55881748815209209628292540917153643678925903600113305305488204665213841469519415
-    11609433057270365759591953092186117381932611793105118548074462379962749567351885
-    75272489122793818301194912983367336244065664308602139494639522473719070217986094
-    37027705392171762931767523846748184676694051320005681271452635608277857713427577
-    89609173637178721468440901224953430146549585371050792279689258923542019956112129
-    02196086403441815981362977477130996051870721134999999837297804995105973173281609
-    63185950244594553469083026425223082533446850352619311881710100031378387528865875
-    33208381420617177669147303598253490428755468731159562863882353787593751957781857
-    780532171226806613001927876611195909216420198
-
- -

Now go and have some fun with big integers on your own!

- -
-
- - -
-
- - - - diff --git a/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/js/jazzy.js b/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/js/jazzy.js deleted file mode 100755 index 009c80d38..000000000 --- a/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/js/jazzy.js +++ /dev/null @@ -1,43 +0,0 @@ -window.jazzy = {'docset': false} -if (typeof window.dash != 'undefined') { - document.documentElement.className += ' dash' - window.jazzy.docset = true -} -if (navigator.userAgent.match(/xcode/i)) { - document.documentElement.className += ' xcode' - window.jazzy.docset = true -} - -// On doc load, toggle the URL hash discussion if present -$(document).ready(function() { - if (!window.jazzy.docset) { - var linkToHash = $('a[href="' + window.location.hash +'"]'); - linkToHash.trigger("click"); - } -}); - -// On token click, toggle its discussion and animate token.marginLeft -$(".token").click(function(event) { - if (window.jazzy.docset) { - return; - } - var link = $(this); - var animationDuration = 300; - $content = link.parent().parent().next(); - $content.slideToggle(animationDuration); - - // Keeps the document from jumping to the hash. - var href = $(this).attr('href'); - if (history.pushState) { - history.pushState({}, '', href); - } else { - location.hash = href; - } - event.preventDefault(); -}); - -// Dumb down quotes within code blocks that delimit strings instead of quotations -// https://github.com/realm/jazzy/issues/714 -$("code q").replaceWith(function () { - return ["\"", $(this).contents(), "\""]; -}); diff --git a/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/js/jazzy.search.js b/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/js/jazzy.search.js deleted file mode 100644 index 54be83cf7..000000000 --- a/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/js/jazzy.search.js +++ /dev/null @@ -1,62 +0,0 @@ -$(function(){ - var searchIndex = lunr(function() { - this.ref('url'); - this.field('name'); - }); - - var $typeahead = $('[data-typeahead]'); - var $form = $typeahead.parents('form'); - var searchURL = $form.attr('action'); - - function displayTemplate(result) { - return result.name; - } - - function suggestionTemplate(result) { - var t = '
'; - t += '' + result.name + ''; - if (result.parent_name) { - t += '' + result.parent_name + ''; - } - t += '
'; - return t; - } - - $typeahead.one('focus', function() { - $form.addClass('loading'); - - $.getJSON(searchURL).then(function(searchData) { - $.each(searchData, function (url, doc) { - searchIndex.add({url: url, name: doc.name}); - }); - - $typeahead.typeahead( - { - highlight: true, - minLength: 3 - }, - { - limit: 10, - display: displayTemplate, - templates: { suggestion: suggestionTemplate }, - source: function(query, sync) { - var results = searchIndex.search(query).map(function(result) { - var doc = searchData[result.ref]; - doc.url = result.ref; - return doc; - }); - sync(results); - } - } - ); - $form.removeClass('loading'); - $typeahead.trigger('focus'); - }); - }); - - var baseURL = searchURL.slice(0, -"search.json".length); - - $typeahead.on('typeahead:select', function(e, result) { - window.location = baseURL + result.url; - }); -}); diff --git a/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/js/jquery.min.js b/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/js/jquery.min.js deleted file mode 100755 index ab28a2472..000000000 --- a/Carthage/Checkouts/BigInt/docs/docsets/BigInt.docset/Contents/Resources/Documents/js/jquery.min.js +++ /dev/null @@ -1,4 +0,0 @@ -/*! jQuery v1.11.1 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */ -!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l="1.11.1",m=function(a,b){return new m.fn.init(a,b)},n=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,o=/^-ms-/,p=/-([\da-z])/gi,q=function(a,b){return b.toUpperCase()};m.fn=m.prototype={jquery:l,constructor:m,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=m.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return m.each(this,a,b)},map:function(a){return this.pushStack(m.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},m.extend=m.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||m.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(e=arguments[h]))for(d in e)a=g[d],c=e[d],g!==c&&(j&&c&&(m.isPlainObject(c)||(b=m.isArray(c)))?(b?(b=!1,f=a&&m.isArray(a)?a:[]):f=a&&m.isPlainObject(a)?a:{},g[d]=m.extend(j,f,c)):void 0!==c&&(g[d]=c));return g},m.extend({expando:"jQuery"+(l+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===m.type(a)},isArray:Array.isArray||function(a){return"array"===m.type(a)},isWindow:function(a){return null!=a&&a==a.window},isNumeric:function(a){return!m.isArray(a)&&a-parseFloat(a)>=0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},isPlainObject:function(a){var b;if(!a||"object"!==m.type(a)||a.nodeType||m.isWindow(a))return!1;try{if(a.constructor&&!j.call(a,"constructor")&&!j.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}if(k.ownLast)for(b in a)return j.call(a,b);for(b in a);return void 0===b||j.call(a,b)},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(b){b&&m.trim(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(o,"ms-").replace(p,q)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=r(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(n,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(r(Object(a))?m.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){var d;if(b){if(g)return g.call(b,a,c);for(d=b.length,c=c?0>c?Math.max(0,d+c):c:0;d>c;c++)if(c in b&&b[c]===a)return c}return-1},merge:function(a,b){var c=+b.length,d=0,e=a.length;while(c>d)a[e++]=b[d++];if(c!==c)while(void 0!==b[d])a[e++]=b[d++];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=r(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(f=a[b],b=a,a=f),m.isFunction(a)?(c=d.call(arguments,2),e=function(){return a.apply(b||this,c.concat(d.call(arguments)))},e.guid=a.guid=a.guid||m.guid++,e):void 0},now:function(){return+new Date},support:k}),m.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function r(a){var b=a.length,c=m.type(a);return"function"===c||m.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var s=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+-new Date,v=a.document,w=0,x=0,y=gb(),z=gb(),A=gb(),B=function(a,b){return a===b&&(l=!0),0},C="undefined",D=1<<31,E={}.hasOwnProperty,F=[],G=F.pop,H=F.push,I=F.push,J=F.slice,K=F.indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(this[b]===a)return b;return-1},L="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",M="[\\x20\\t\\r\\n\\f]",N="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",O=N.replace("w","w#"),P="\\["+M+"*("+N+")(?:"+M+"*([*^$|!~]?=)"+M+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+O+"))|)"+M+"*\\]",Q=":("+N+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+P+")*)|.*)\\)|)",R=new RegExp("^"+M+"+|((?:^|[^\\\\])(?:\\\\.)*)"+M+"+$","g"),S=new RegExp("^"+M+"*,"+M+"*"),T=new RegExp("^"+M+"*([>+~]|"+M+")"+M+"*"),U=new RegExp("="+M+"*([^\\]'\"]*?)"+M+"*\\]","g"),V=new RegExp(Q),W=new RegExp("^"+O+"$"),X={ID:new RegExp("^#("+N+")"),CLASS:new RegExp("^\\.("+N+")"),TAG:new RegExp("^("+N.replace("w","w*")+")"),ATTR:new RegExp("^"+P),PSEUDO:new RegExp("^"+Q),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+L+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Y=/^(?:input|select|textarea|button)$/i,Z=/^h\d$/i,$=/^[^{]+\{\s*\[native \w/,_=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ab=/[+~]/,bb=/'|\\/g,cb=new RegExp("\\\\([\\da-f]{1,6}"+M+"?|("+M+")|.)","ig"),db=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)};try{I.apply(F=J.call(v.childNodes),v.childNodes),F[v.childNodes.length].nodeType}catch(eb){I={apply:F.length?function(a,b){H.apply(a,J.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function fb(a,b,d,e){var f,h,j,k,l,o,r,s,w,x;if((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,d=d||[],!a||"string"!=typeof a)return d;if(1!==(k=b.nodeType)&&9!==k)return[];if(p&&!e){if(f=_.exec(a))if(j=f[1]){if(9===k){if(h=b.getElementById(j),!h||!h.parentNode)return d;if(h.id===j)return d.push(h),d}else if(b.ownerDocument&&(h=b.ownerDocument.getElementById(j))&&t(b,h)&&h.id===j)return d.push(h),d}else{if(f[2])return I.apply(d,b.getElementsByTagName(a)),d;if((j=f[3])&&c.getElementsByClassName&&b.getElementsByClassName)return I.apply(d,b.getElementsByClassName(j)),d}if(c.qsa&&(!q||!q.test(a))){if(s=r=u,w=b,x=9===k&&a,1===k&&"object"!==b.nodeName.toLowerCase()){o=g(a),(r=b.getAttribute("id"))?s=r.replace(bb,"\\$&"):b.setAttribute("id",s),s="[id='"+s+"'] ",l=o.length;while(l--)o[l]=s+qb(o[l]);w=ab.test(a)&&ob(b.parentNode)||b,x=o.join(",")}if(x)try{return I.apply(d,w.querySelectorAll(x)),d}catch(y){}finally{r||b.removeAttribute("id")}}}return i(a.replace(R,"$1"),b,d,e)}function gb(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function hb(a){return a[u]=!0,a}function ib(a){var b=n.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function jb(a,b){var c=a.split("|"),e=a.length;while(e--)d.attrHandle[c[e]]=b}function kb(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||D)-(~a.sourceIndex||D);if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function lb(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function mb(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function nb(a){return hb(function(b){return b=+b,hb(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function ob(a){return a&&typeof a.getElementsByTagName!==C&&a}c=fb.support={},f=fb.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},m=fb.setDocument=function(a){var b,e=a?a.ownerDocument||a:v,g=e.defaultView;return e!==n&&9===e.nodeType&&e.documentElement?(n=e,o=e.documentElement,p=!f(e),g&&g!==g.top&&(g.addEventListener?g.addEventListener("unload",function(){m()},!1):g.attachEvent&&g.attachEvent("onunload",function(){m()})),c.attributes=ib(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=ib(function(a){return a.appendChild(e.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=$.test(e.getElementsByClassName)&&ib(function(a){return a.innerHTML="
",a.firstChild.className="i",2===a.getElementsByClassName("i").length}),c.getById=ib(function(a){return o.appendChild(a).id=u,!e.getElementsByName||!e.getElementsByName(u).length}),c.getById?(d.find.ID=function(a,b){if(typeof b.getElementById!==C&&p){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){var c=typeof a.getAttributeNode!==C&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return typeof b.getElementsByTagName!==C?b.getElementsByTagName(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){return typeof b.getElementsByClassName!==C&&p?b.getElementsByClassName(a):void 0},r=[],q=[],(c.qsa=$.test(e.querySelectorAll))&&(ib(function(a){a.innerHTML="",a.querySelectorAll("[msallowclip^='']").length&&q.push("[*^$]="+M+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+M+"*(?:value|"+L+")"),a.querySelectorAll(":checked").length||q.push(":checked")}),ib(function(a){var b=e.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+M+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=$.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&ib(function(a){c.disconnectedMatch=s.call(a,"div"),s.call(a,"[s!='']:x"),r.push("!=",Q)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=$.test(o.compareDocumentPosition),t=b||$.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===e||a.ownerDocument===v&&t(v,a)?-1:b===e||b.ownerDocument===v&&t(v,b)?1:k?K.call(k,a)-K.call(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,f=a.parentNode,g=b.parentNode,h=[a],i=[b];if(!f||!g)return a===e?-1:b===e?1:f?-1:g?1:k?K.call(k,a)-K.call(k,b):0;if(f===g)return kb(a,b);c=a;while(c=c.parentNode)h.unshift(c);c=b;while(c=c.parentNode)i.unshift(c);while(h[d]===i[d])d++;return d?kb(h[d],i[d]):h[d]===v?-1:i[d]===v?1:0},e):n},fb.matches=function(a,b){return fb(a,null,null,b)},fb.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(U,"='$1']"),!(!c.matchesSelector||!p||r&&r.test(b)||q&&q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return fb(b,n,null,[a]).length>0},fb.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},fb.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&E.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},fb.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},fb.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return k=null,a},e=fb.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=fb.selectors={cacheLength:50,createPseudo:hb,match:X,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(cb,db),a[3]=(a[3]||a[4]||a[5]||"").replace(cb,db),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||fb.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&fb.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return X.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&V.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(cb,db).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+M+")"+a+"("+M+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||typeof a.getAttribute!==C&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=fb.attr(d,a);return null==e?"!="===b:b?(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e+" ").indexOf(c)>-1:"|="===b?e===c||e.slice(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h;if(q){if(f){while(p){l=b;while(l=l[p])if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){k=q[u]||(q[u]={}),j=k[a]||[],n=j[0]===w&&j[1],m=j[0]===w&&j[2],l=n&&q.childNodes[n];while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if(1===l.nodeType&&++m&&l===b){k[a]=[w,n,m];break}}else if(s&&(j=(b[u]||(b[u]={}))[a])&&j[0]===w)m=j[1];else while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if((h?l.nodeName.toLowerCase()===r:1===l.nodeType)&&++m&&(s&&((l[u]||(l[u]={}))[a]=[w,m]),l===b))break;return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||fb.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?hb(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=K.call(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:hb(function(a){var b=[],c=[],d=h(a.replace(R,"$1"));return d[u]?hb(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),!c.pop()}}),has:hb(function(a){return function(b){return fb(a,b).length>0}}),contains:hb(function(a){return function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:hb(function(a){return W.test(a||"")||fb.error("unsupported lang: "+a),a=a.replace(cb,db).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return Z.test(a.nodeName)},input:function(a){return Y.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:nb(function(){return[0]}),last:nb(function(a,b){return[b-1]}),eq:nb(function(a,b,c){return[0>c?c+b:c]}),even:nb(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:nb(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:nb(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:nb(function(a,b,c){for(var d=0>c?c+b:c;++db;b++)d+=a[b].value;return d}function rb(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=x++;return b.first?function(b,c,f){while(b=b[d])if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j=[w,f];if(g){while(b=b[d])if((1===b.nodeType||e)&&a(b,c,g))return!0}else while(b=b[d])if(1===b.nodeType||e){if(i=b[u]||(b[u]={}),(h=i[d])&&h[0]===w&&h[1]===f)return j[2]=h[2];if(i[d]=j,j[2]=a(b,c,g))return!0}}}function sb(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function tb(a,b,c){for(var d=0,e=b.length;e>d;d++)fb(a,b[d],c);return c}function ub(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(!c||c(f,d,e))&&(g.push(f),j&&b.push(h));return g}function vb(a,b,c,d,e,f){return d&&!d[u]&&(d=vb(d)),e&&!e[u]&&(e=vb(e,f)),hb(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||tb(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:ub(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=ub(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?K.call(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=ub(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):I.apply(g,r)})}function wb(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=rb(function(a){return a===b},h,!0),l=rb(function(a){return K.call(b,a)>-1},h,!0),m=[function(a,c,d){return!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d))}];f>i;i++)if(c=d.relative[a[i].type])m=[rb(sb(m),c)];else{if(c=d.filter[a[i].type].apply(null,a[i].matches),c[u]){for(e=++i;f>e;e++)if(d.relative[a[e].type])break;return vb(i>1&&sb(m),i>1&&qb(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(R,"$1"),c,e>i&&wb(a.slice(i,e)),f>e&&wb(a=a.slice(e)),f>e&&qb(a))}m.push(c)}return sb(m)}function xb(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,h,i,k){var l,m,o,p=0,q="0",r=f&&[],s=[],t=j,u=f||e&&d.find.TAG("*",k),v=w+=null==t?1:Math.random()||.1,x=u.length;for(k&&(j=g!==n&&g);q!==x&&null!=(l=u[q]);q++){if(e&&l){m=0;while(o=a[m++])if(o(l,g,h)){i.push(l);break}k&&(w=v)}c&&((l=!o&&l)&&p--,f&&r.push(l))}if(p+=q,c&&q!==p){m=0;while(o=b[m++])o(r,s,g,h);if(f){if(p>0)while(q--)r[q]||s[q]||(s[q]=G.call(i));s=ub(s)}I.apply(i,s),k&&!f&&s.length>0&&p+b.length>1&&fb.uniqueSort(i)}return k&&(w=v,j=t),r};return c?hb(f):f}return h=fb.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){b||(b=g(a)),c=b.length;while(c--)f=wb(b[c]),f[u]?d.push(f):e.push(f);f=A(a,xb(e,d)),f.selector=a}return f},i=fb.select=function(a,b,e,f){var i,j,k,l,m,n="function"==typeof a&&a,o=!f&&g(a=n.selector||a);if(e=e||[],1===o.length){if(j=o[0]=o[0].slice(0),j.length>2&&"ID"===(k=j[0]).type&&c.getById&&9===b.nodeType&&p&&d.relative[j[1].type]){if(b=(d.find.ID(k.matches[0].replace(cb,db),b)||[])[0],!b)return e;n&&(b=b.parentNode),a=a.slice(j.shift().value.length)}i=X.needsContext.test(a)?0:j.length;while(i--){if(k=j[i],d.relative[l=k.type])break;if((m=d.find[l])&&(f=m(k.matches[0].replace(cb,db),ab.test(j[0].type)&&ob(b.parentNode)||b))){if(j.splice(i,1),a=f.length&&qb(j),!a)return I.apply(e,f),e;break}}}return(n||h(a,o))(f,b,!p,e,ab.test(a)&&ob(b.parentNode)||b),e},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=ib(function(a){return 1&a.compareDocumentPosition(n.createElement("div"))}),ib(function(a){return a.innerHTML="","#"===a.firstChild.getAttribute("href")})||jb("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&ib(function(a){return a.innerHTML="",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||jb("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),ib(function(a){return null==a.getAttribute("disabled")})||jb(L,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),fb}(a);m.find=s,m.expr=s.selectors,m.expr[":"]=m.expr.pseudos,m.unique=s.uniqueSort,m.text=s.getText,m.isXMLDoc=s.isXML,m.contains=s.contains;var t=m.expr.match.needsContext,u=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,v=/^.[^:#\[\.,]*$/;function w(a,b,c){if(m.isFunction(b))return m.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return m.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(v.test(b))return m.filter(b,a,c);b=m.filter(b,a)}return m.grep(a,function(a){return m.inArray(a,b)>=0!==c})}m.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?m.find.matchesSelector(d,a)?[d]:[]:m.find.matches(a,m.grep(b,function(a){return 1===a.nodeType}))},m.fn.extend({find:function(a){var b,c=[],d=this,e=d.length;if("string"!=typeof a)return this.pushStack(m(a).filter(function(){for(b=0;e>b;b++)if(m.contains(d[b],this))return!0}));for(b=0;e>b;b++)m.find(a,d[b],c);return c=this.pushStack(e>1?m.unique(c):c),c.selector=this.selector?this.selector+" "+a:a,c},filter:function(a){return this.pushStack(w(this,a||[],!1))},not:function(a){return this.pushStack(w(this,a||[],!0))},is:function(a){return!!w(this,"string"==typeof a&&t.test(a)?m(a):a||[],!1).length}});var x,y=a.document,z=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,A=m.fn.init=function(a,b){var c,d;if(!a)return this;if("string"==typeof a){if(c="<"===a.charAt(0)&&">"===a.charAt(a.length-1)&&a.length>=3?[null,a,null]:z.exec(a),!c||!c[1]&&b)return!b||b.jquery?(b||x).find(a):this.constructor(b).find(a);if(c[1]){if(b=b instanceof m?b[0]:b,m.merge(this,m.parseHTML(c[1],b&&b.nodeType?b.ownerDocument||b:y,!0)),u.test(c[1])&&m.isPlainObject(b))for(c in b)m.isFunction(this[c])?this[c](b[c]):this.attr(c,b[c]);return this}if(d=y.getElementById(c[2]),d&&d.parentNode){if(d.id!==c[2])return x.find(a);this.length=1,this[0]=d}return this.context=y,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):m.isFunction(a)?"undefined"!=typeof x.ready?x.ready(a):a(m):(void 0!==a.selector&&(this.selector=a.selector,this.context=a.context),m.makeArray(a,this))};A.prototype=m.fn,x=m(y);var B=/^(?:parents|prev(?:Until|All))/,C={children:!0,contents:!0,next:!0,prev:!0};m.extend({dir:function(a,b,c){var d=[],e=a[b];while(e&&9!==e.nodeType&&(void 0===c||1!==e.nodeType||!m(e).is(c)))1===e.nodeType&&d.push(e),e=e[b];return d},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}}),m.fn.extend({has:function(a){var b,c=m(a,this),d=c.length;return this.filter(function(){for(b=0;d>b;b++)if(m.contains(this,c[b]))return!0})},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=t.test(a)||"string"!=typeof a?m(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&m.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?m.unique(f):f)},index:function(a){return a?"string"==typeof a?m.inArray(this[0],m(a)):m.inArray(a.jquery?a[0]:a,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(m.unique(m.merge(this.get(),m(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function D(a,b){do a=a[b];while(a&&1!==a.nodeType);return a}m.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return m.dir(a,"parentNode")},parentsUntil:function(a,b,c){return m.dir(a,"parentNode",c)},next:function(a){return D(a,"nextSibling")},prev:function(a){return D(a,"previousSibling")},nextAll:function(a){return m.dir(a,"nextSibling")},prevAll:function(a){return m.dir(a,"previousSibling")},nextUntil:function(a,b,c){return m.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return m.dir(a,"previousSibling",c)},siblings:function(a){return m.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return m.sibling(a.firstChild)},contents:function(a){return m.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:m.merge([],a.childNodes)}},function(a,b){m.fn[a]=function(c,d){var e=m.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=m.filter(d,e)),this.length>1&&(C[a]||(e=m.unique(e)),B.test(a)&&(e=e.reverse())),this.pushStack(e)}});var E=/\S+/g,F={};function G(a){var b=F[a]={};return m.each(a.match(E)||[],function(a,c){b[c]=!0}),b}m.Callbacks=function(a){a="string"==typeof a?F[a]||G(a):m.extend({},a);var b,c,d,e,f,g,h=[],i=!a.once&&[],j=function(l){for(c=a.memory&&l,d=!0,f=g||0,g=0,e=h.length,b=!0;h&&e>f;f++)if(h[f].apply(l[0],l[1])===!1&&a.stopOnFalse){c=!1;break}b=!1,h&&(i?i.length&&j(i.shift()):c?h=[]:k.disable())},k={add:function(){if(h){var d=h.length;!function f(b){m.each(b,function(b,c){var d=m.type(c);"function"===d?a.unique&&k.has(c)||h.push(c):c&&c.length&&"string"!==d&&f(c)})}(arguments),b?e=h.length:c&&(g=d,j(c))}return this},remove:function(){return h&&m.each(arguments,function(a,c){var d;while((d=m.inArray(c,h,d))>-1)h.splice(d,1),b&&(e>=d&&e--,f>=d&&f--)}),this},has:function(a){return a?m.inArray(a,h)>-1:!(!h||!h.length)},empty:function(){return h=[],e=0,this},disable:function(){return h=i=c=void 0,this},disabled:function(){return!h},lock:function(){return i=void 0,c||k.disable(),this},locked:function(){return!i},fireWith:function(a,c){return!h||d&&!i||(c=c||[],c=[a,c.slice?c.slice():c],b?i.push(c):j(c)),this},fire:function(){return k.fireWith(this,arguments),this},fired:function(){return!!d}};return k},m.extend({Deferred:function(a){var b=[["resolve","done",m.Callbacks("once memory"),"resolved"],["reject","fail",m.Callbacks("once memory"),"rejected"],["notify","progress",m.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return m.Deferred(function(c){m.each(b,function(b,f){var g=m.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&m.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?m.extend(a,d):d}},e={};return d.pipe=d.then,m.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=d.call(arguments),e=c.length,f=1!==e||a&&m.isFunction(a.promise)?e:0,g=1===f?a:m.Deferred(),h=function(a,b,c){return function(e){b[a]=this,c[a]=arguments.length>1?d.call(arguments):e,c===i?g.notifyWith(b,c):--f||g.resolveWith(b,c)}},i,j,k;if(e>1)for(i=new Array(e),j=new Array(e),k=new Array(e);e>b;b++)c[b]&&m.isFunction(c[b].promise)?c[b].promise().done(h(b,k,c)).fail(g.reject).progress(h(b,j,i)):--f;return f||g.resolveWith(k,c),g.promise()}});var H;m.fn.ready=function(a){return m.ready.promise().done(a),this},m.extend({isReady:!1,readyWait:1,holdReady:function(a){a?m.readyWait++:m.ready(!0)},ready:function(a){if(a===!0?!--m.readyWait:!m.isReady){if(!y.body)return setTimeout(m.ready);m.isReady=!0,a!==!0&&--m.readyWait>0||(H.resolveWith(y,[m]),m.fn.triggerHandler&&(m(y).triggerHandler("ready"),m(y).off("ready")))}}});function I(){y.addEventListener?(y.removeEventListener("DOMContentLoaded",J,!1),a.removeEventListener("load",J,!1)):(y.detachEvent("onreadystatechange",J),a.detachEvent("onload",J))}function J(){(y.addEventListener||"load"===event.type||"complete"===y.readyState)&&(I(),m.ready())}m.ready.promise=function(b){if(!H)if(H=m.Deferred(),"complete"===y.readyState)setTimeout(m.ready);else if(y.addEventListener)y.addEventListener("DOMContentLoaded",J,!1),a.addEventListener("load",J,!1);else{y.attachEvent("onreadystatechange",J),a.attachEvent("onload",J);var c=!1;try{c=null==a.frameElement&&y.documentElement}catch(d){}c&&c.doScroll&&!function e(){if(!m.isReady){try{c.doScroll("left")}catch(a){return setTimeout(e,50)}I(),m.ready()}}()}return H.promise(b)};var K="undefined",L;for(L in m(k))break;k.ownLast="0"!==L,k.inlineBlockNeedsLayout=!1,m(function(){var a,b,c,d;c=y.getElementsByTagName("body")[0],c&&c.style&&(b=y.createElement("div"),d=y.createElement("div"),d.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px",c.appendChild(d).appendChild(b),typeof b.style.zoom!==K&&(b.style.cssText="display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1",k.inlineBlockNeedsLayout=a=3===b.offsetWidth,a&&(c.style.zoom=1)),c.removeChild(d))}),function(){var a=y.createElement("div");if(null==k.deleteExpando){k.deleteExpando=!0;try{delete a.test}catch(b){k.deleteExpando=!1}}a=null}(),m.acceptData=function(a){var b=m.noData[(a.nodeName+" ").toLowerCase()],c=+a.nodeType||1;return 1!==c&&9!==c?!1:!b||b!==!0&&a.getAttribute("classid")===b};var M=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,N=/([A-Z])/g;function O(a,b,c){if(void 0===c&&1===a.nodeType){var d="data-"+b.replace(N,"-$1").toLowerCase();if(c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:M.test(c)?m.parseJSON(c):c}catch(e){}m.data(a,b,c)}else c=void 0}return c}function P(a){var b;for(b in a)if(("data"!==b||!m.isEmptyObject(a[b]))&&"toJSON"!==b)return!1;return!0}function Q(a,b,d,e){if(m.acceptData(a)){var f,g,h=m.expando,i=a.nodeType,j=i?m.cache:a,k=i?a[h]:a[h]&&h; -if(k&&j[k]&&(e||j[k].data)||void 0!==d||"string"!=typeof b)return k||(k=i?a[h]=c.pop()||m.guid++:h),j[k]||(j[k]=i?{}:{toJSON:m.noop}),("object"==typeof b||"function"==typeof b)&&(e?j[k]=m.extend(j[k],b):j[k].data=m.extend(j[k].data,b)),g=j[k],e||(g.data||(g.data={}),g=g.data),void 0!==d&&(g[m.camelCase(b)]=d),"string"==typeof b?(f=g[b],null==f&&(f=g[m.camelCase(b)])):f=g,f}}function R(a,b,c){if(m.acceptData(a)){var d,e,f=a.nodeType,g=f?m.cache:a,h=f?a[m.expando]:m.expando;if(g[h]){if(b&&(d=c?g[h]:g[h].data)){m.isArray(b)?b=b.concat(m.map(b,m.camelCase)):b in d?b=[b]:(b=m.camelCase(b),b=b in d?[b]:b.split(" ")),e=b.length;while(e--)delete d[b[e]];if(c?!P(d):!m.isEmptyObject(d))return}(c||(delete g[h].data,P(g[h])))&&(f?m.cleanData([a],!0):k.deleteExpando||g!=g.window?delete g[h]:g[h]=null)}}}m.extend({cache:{},noData:{"applet ":!0,"embed ":!0,"object ":"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(a){return a=a.nodeType?m.cache[a[m.expando]]:a[m.expando],!!a&&!P(a)},data:function(a,b,c){return Q(a,b,c)},removeData:function(a,b){return R(a,b)},_data:function(a,b,c){return Q(a,b,c,!0)},_removeData:function(a,b){return R(a,b,!0)}}),m.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=m.data(f),1===f.nodeType&&!m._data(f,"parsedAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=m.camelCase(d.slice(5)),O(f,d,e[d])));m._data(f,"parsedAttrs",!0)}return e}return"object"==typeof a?this.each(function(){m.data(this,a)}):arguments.length>1?this.each(function(){m.data(this,a,b)}):f?O(f,a,m.data(f,a)):void 0},removeData:function(a){return this.each(function(){m.removeData(this,a)})}}),m.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=m._data(a,b),c&&(!d||m.isArray(c)?d=m._data(a,b,m.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=m.queue(a,b),d=c.length,e=c.shift(),f=m._queueHooks(a,b),g=function(){m.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return m._data(a,c)||m._data(a,c,{empty:m.Callbacks("once memory").add(function(){m._removeData(a,b+"queue"),m._removeData(a,c)})})}}),m.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.lengthh;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f},W=/^(?:checkbox|radio)$/i;!function(){var a=y.createElement("input"),b=y.createElement("div"),c=y.createDocumentFragment();if(b.innerHTML="
a",k.leadingWhitespace=3===b.firstChild.nodeType,k.tbody=!b.getElementsByTagName("tbody").length,k.htmlSerialize=!!b.getElementsByTagName("link").length,k.html5Clone="<:nav>"!==y.createElement("nav").cloneNode(!0).outerHTML,a.type="checkbox",a.checked=!0,c.appendChild(a),k.appendChecked=a.checked,b.innerHTML="",k.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue,c.appendChild(b),b.innerHTML="",k.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,k.noCloneEvent=!0,b.attachEvent&&(b.attachEvent("onclick",function(){k.noCloneEvent=!1}),b.cloneNode(!0).click()),null==k.deleteExpando){k.deleteExpando=!0;try{delete b.test}catch(d){k.deleteExpando=!1}}}(),function(){var b,c,d=y.createElement("div");for(b in{submit:!0,change:!0,focusin:!0})c="on"+b,(k[b+"Bubbles"]=c in a)||(d.setAttribute(c,"t"),k[b+"Bubbles"]=d.attributes[c].expando===!1);d=null}();var X=/^(?:input|select|textarea)$/i,Y=/^key/,Z=/^(?:mouse|pointer|contextmenu)|click/,$=/^(?:focusinfocus|focusoutblur)$/,_=/^([^.]*)(?:\.(.+)|)$/;function ab(){return!0}function bb(){return!1}function cb(){try{return y.activeElement}catch(a){}}m.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,n,o,p,q,r=m._data(a);if(r){c.handler&&(i=c,c=i.handler,e=i.selector),c.guid||(c.guid=m.guid++),(g=r.events)||(g=r.events={}),(k=r.handle)||(k=r.handle=function(a){return typeof m===K||a&&m.event.triggered===a.type?void 0:m.event.dispatch.apply(k.elem,arguments)},k.elem=a),b=(b||"").match(E)||[""],h=b.length;while(h--)f=_.exec(b[h])||[],o=q=f[1],p=(f[2]||"").split(".").sort(),o&&(j=m.event.special[o]||{},o=(e?j.delegateType:j.bindType)||o,j=m.event.special[o]||{},l=m.extend({type:o,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&m.expr.match.needsContext.test(e),namespace:p.join(".")},i),(n=g[o])||(n=g[o]=[],n.delegateCount=0,j.setup&&j.setup.call(a,d,p,k)!==!1||(a.addEventListener?a.addEventListener(o,k,!1):a.attachEvent&&a.attachEvent("on"+o,k))),j.add&&(j.add.call(a,l),l.handler.guid||(l.handler.guid=c.guid)),e?n.splice(n.delegateCount++,0,l):n.push(l),m.event.global[o]=!0);a=null}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,n,o,p,q,r=m.hasData(a)&&m._data(a);if(r&&(k=r.events)){b=(b||"").match(E)||[""],j=b.length;while(j--)if(h=_.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o){l=m.event.special[o]||{},o=(d?l.delegateType:l.bindType)||o,n=k[o]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),i=f=n.length;while(f--)g=n[f],!e&&q!==g.origType||c&&c.guid!==g.guid||h&&!h.test(g.namespace)||d&&d!==g.selector&&("**"!==d||!g.selector)||(n.splice(f,1),g.selector&&n.delegateCount--,l.remove&&l.remove.call(a,g));i&&!n.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||m.removeEvent(a,o,r.handle),delete k[o])}else for(o in k)m.event.remove(a,o+b[j],c,d,!0);m.isEmptyObject(k)&&(delete r.handle,m._removeData(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,l,n,o=[d||y],p=j.call(b,"type")?b.type:b,q=j.call(b,"namespace")?b.namespace.split("."):[];if(h=l=d=d||y,3!==d.nodeType&&8!==d.nodeType&&!$.test(p+m.event.triggered)&&(p.indexOf(".")>=0&&(q=p.split("."),p=q.shift(),q.sort()),g=p.indexOf(":")<0&&"on"+p,b=b[m.expando]?b:new m.Event(p,"object"==typeof b&&b),b.isTrigger=e?2:3,b.namespace=q.join("."),b.namespace_re=b.namespace?new RegExp("(^|\\.)"+q.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=d),c=null==c?[b]:m.makeArray(c,[b]),k=m.event.special[p]||{},e||!k.trigger||k.trigger.apply(d,c)!==!1)){if(!e&&!k.noBubble&&!m.isWindow(d)){for(i=k.delegateType||p,$.test(i+p)||(h=h.parentNode);h;h=h.parentNode)o.push(h),l=h;l===(d.ownerDocument||y)&&o.push(l.defaultView||l.parentWindow||a)}n=0;while((h=o[n++])&&!b.isPropagationStopped())b.type=n>1?i:k.bindType||p,f=(m._data(h,"events")||{})[b.type]&&m._data(h,"handle"),f&&f.apply(h,c),f=g&&h[g],f&&f.apply&&m.acceptData(h)&&(b.result=f.apply(h,c),b.result===!1&&b.preventDefault());if(b.type=p,!e&&!b.isDefaultPrevented()&&(!k._default||k._default.apply(o.pop(),c)===!1)&&m.acceptData(d)&&g&&d[p]&&!m.isWindow(d)){l=d[g],l&&(d[g]=null),m.event.triggered=p;try{d[p]()}catch(r){}m.event.triggered=void 0,l&&(d[g]=l)}return b.result}},dispatch:function(a){a=m.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(m._data(this,"events")||{})[a.type]||[],k=m.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=m.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,g=0;while((e=f.handlers[g++])&&!a.isImmediatePropagationStopped())(!a.namespace_re||a.namespace_re.test(e.namespace))&&(a.handleObj=e,a.data=e.data,c=((m.event.special[e.origType]||{}).handle||e.handler).apply(f.elem,i),void 0!==c&&(a.result=c)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&(!a.button||"click"!==a.type))for(;i!=this;i=i.parentNode||this)if(1===i.nodeType&&(i.disabled!==!0||"click"!==a.type)){for(e=[],f=0;h>f;f++)d=b[f],c=d.selector+" ",void 0===e[c]&&(e[c]=d.needsContext?m(c,this).index(i)>=0:m.find(c,this,null,[i]).length),e[c]&&e.push(d);e.length&&g.push({elem:i,handlers:e})}return h]","i"),hb=/^\s+/,ib=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,jb=/<([\w:]+)/,kb=/\s*$/g,rb={option:[1,""],legend:[1,"
","
"],area:[1,"",""],param:[1,"",""],thead:[1,"","
"],tr:[2,"","
"],col:[2,"","
"],td:[3,"","
"],_default:k.htmlSerialize?[0,"",""]:[1,"X
","
"]},sb=db(y),tb=sb.appendChild(y.createElement("div"));rb.optgroup=rb.option,rb.tbody=rb.tfoot=rb.colgroup=rb.caption=rb.thead,rb.th=rb.td;function ub(a,b){var c,d,e=0,f=typeof a.getElementsByTagName!==K?a.getElementsByTagName(b||"*"):typeof a.querySelectorAll!==K?a.querySelectorAll(b||"*"):void 0;if(!f)for(f=[],c=a.childNodes||a;null!=(d=c[e]);e++)!b||m.nodeName(d,b)?f.push(d):m.merge(f,ub(d,b));return void 0===b||b&&m.nodeName(a,b)?m.merge([a],f):f}function vb(a){W.test(a.type)&&(a.defaultChecked=a.checked)}function wb(a,b){return m.nodeName(a,"table")&&m.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function xb(a){return a.type=(null!==m.find.attr(a,"type"))+"/"+a.type,a}function yb(a){var b=pb.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function zb(a,b){for(var c,d=0;null!=(c=a[d]);d++)m._data(c,"globalEval",!b||m._data(b[d],"globalEval"))}function Ab(a,b){if(1===b.nodeType&&m.hasData(a)){var c,d,e,f=m._data(a),g=m._data(b,f),h=f.events;if(h){delete g.handle,g.events={};for(c in h)for(d=0,e=h[c].length;e>d;d++)m.event.add(b,c,h[c][d])}g.data&&(g.data=m.extend({},g.data))}}function Bb(a,b){var c,d,e;if(1===b.nodeType){if(c=b.nodeName.toLowerCase(),!k.noCloneEvent&&b[m.expando]){e=m._data(b);for(d in e.events)m.removeEvent(b,d,e.handle);b.removeAttribute(m.expando)}"script"===c&&b.text!==a.text?(xb(b).text=a.text,yb(b)):"object"===c?(b.parentNode&&(b.outerHTML=a.outerHTML),k.html5Clone&&a.innerHTML&&!m.trim(b.innerHTML)&&(b.innerHTML=a.innerHTML)):"input"===c&&W.test(a.type)?(b.defaultChecked=b.checked=a.checked,b.value!==a.value&&(b.value=a.value)):"option"===c?b.defaultSelected=b.selected=a.defaultSelected:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}}m.extend({clone:function(a,b,c){var d,e,f,g,h,i=m.contains(a.ownerDocument,a);if(k.html5Clone||m.isXMLDoc(a)||!gb.test("<"+a.nodeName+">")?f=a.cloneNode(!0):(tb.innerHTML=a.outerHTML,tb.removeChild(f=tb.firstChild)),!(k.noCloneEvent&&k.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||m.isXMLDoc(a)))for(d=ub(f),h=ub(a),g=0;null!=(e=h[g]);++g)d[g]&&Bb(e,d[g]);if(b)if(c)for(h=h||ub(a),d=d||ub(f),g=0;null!=(e=h[g]);g++)Ab(e,d[g]);else Ab(a,f);return d=ub(f,"script"),d.length>0&&zb(d,!i&&ub(a,"script")),d=h=e=null,f},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,l,n=a.length,o=db(b),p=[],q=0;n>q;q++)if(f=a[q],f||0===f)if("object"===m.type(f))m.merge(p,f.nodeType?[f]:f);else if(lb.test(f)){h=h||o.appendChild(b.createElement("div")),i=(jb.exec(f)||["",""])[1].toLowerCase(),l=rb[i]||rb._default,h.innerHTML=l[1]+f.replace(ib,"<$1>")+l[2],e=l[0];while(e--)h=h.lastChild;if(!k.leadingWhitespace&&hb.test(f)&&p.push(b.createTextNode(hb.exec(f)[0])),!k.tbody){f="table"!==i||kb.test(f)?""!==l[1]||kb.test(f)?0:h:h.firstChild,e=f&&f.childNodes.length;while(e--)m.nodeName(j=f.childNodes[e],"tbody")&&!j.childNodes.length&&f.removeChild(j)}m.merge(p,h.childNodes),h.textContent="";while(h.firstChild)h.removeChild(h.firstChild);h=o.lastChild}else p.push(b.createTextNode(f));h&&o.removeChild(h),k.appendChecked||m.grep(ub(p,"input"),vb),q=0;while(f=p[q++])if((!d||-1===m.inArray(f,d))&&(g=m.contains(f.ownerDocument,f),h=ub(o.appendChild(f),"script"),g&&zb(h),c)){e=0;while(f=h[e++])ob.test(f.type||"")&&c.push(f)}return h=null,o},cleanData:function(a,b){for(var d,e,f,g,h=0,i=m.expando,j=m.cache,l=k.deleteExpando,n=m.event.special;null!=(d=a[h]);h++)if((b||m.acceptData(d))&&(f=d[i],g=f&&j[f])){if(g.events)for(e in g.events)n[e]?m.event.remove(d,e):m.removeEvent(d,e,g.handle);j[f]&&(delete j[f],l?delete d[i]:typeof d.removeAttribute!==K?d.removeAttribute(i):d[i]=null,c.push(f))}}}),m.fn.extend({text:function(a){return V(this,function(a){return void 0===a?m.text(this):this.empty().append((this[0]&&this[0].ownerDocument||y).createTextNode(a))},null,a,arguments.length)},append:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=wb(this,a);b.appendChild(a)}})},prepend:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=wb(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=a?m.filter(a,this):this,e=0;null!=(c=d[e]);e++)b||1!==c.nodeType||m.cleanData(ub(c)),c.parentNode&&(b&&m.contains(c.ownerDocument,c)&&zb(ub(c,"script")),c.parentNode.removeChild(c));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++){1===a.nodeType&&m.cleanData(ub(a,!1));while(a.firstChild)a.removeChild(a.firstChild);a.options&&m.nodeName(a,"select")&&(a.options.length=0)}return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return m.clone(this,a,b)})},html:function(a){return V(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a)return 1===b.nodeType?b.innerHTML.replace(fb,""):void 0;if(!("string"!=typeof a||mb.test(a)||!k.htmlSerialize&&gb.test(a)||!k.leadingWhitespace&&hb.test(a)||rb[(jb.exec(a)||["",""])[1].toLowerCase()])){a=a.replace(ib,"<$1>");try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(m.cleanData(ub(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=arguments[0];return this.domManip(arguments,function(b){a=this.parentNode,m.cleanData(ub(this)),a&&a.replaceChild(b,this)}),a&&(a.length||a.nodeType)?this:this.remove()},detach:function(a){return this.remove(a,!0)},domManip:function(a,b){a=e.apply([],a);var c,d,f,g,h,i,j=0,l=this.length,n=this,o=l-1,p=a[0],q=m.isFunction(p);if(q||l>1&&"string"==typeof p&&!k.checkClone&&nb.test(p))return this.each(function(c){var d=n.eq(c);q&&(a[0]=p.call(this,c,d.html())),d.domManip(a,b)});if(l&&(i=m.buildFragment(a,this[0].ownerDocument,!1,this),c=i.firstChild,1===i.childNodes.length&&(i=c),c)){for(g=m.map(ub(i,"script"),xb),f=g.length;l>j;j++)d=i,j!==o&&(d=m.clone(d,!0,!0),f&&m.merge(g,ub(d,"script"))),b.call(this[j],d,j);if(f)for(h=g[g.length-1].ownerDocument,m.map(g,yb),j=0;f>j;j++)d=g[j],ob.test(d.type||"")&&!m._data(d,"globalEval")&&m.contains(h,d)&&(d.src?m._evalUrl&&m._evalUrl(d.src):m.globalEval((d.text||d.textContent||d.innerHTML||"").replace(qb,"")));i=c=null}return this}}),m.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){m.fn[a]=function(a){for(var c,d=0,e=[],g=m(a),h=g.length-1;h>=d;d++)c=d===h?this:this.clone(!0),m(g[d])[b](c),f.apply(e,c.get());return this.pushStack(e)}});var Cb,Db={};function Eb(b,c){var d,e=m(c.createElement(b)).appendTo(c.body),f=a.getDefaultComputedStyle&&(d=a.getDefaultComputedStyle(e[0]))?d.display:m.css(e[0],"display");return e.detach(),f}function Fb(a){var b=y,c=Db[a];return c||(c=Eb(a,b),"none"!==c&&c||(Cb=(Cb||m("