Giter Club home page Giter Club logo

uint128's People

Contributors

adamnemecek avatar camunro avatar gianpispi avatar gongzhang avatar jitsusama avatar jzau avatar snofla avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

uint128's Issues

Convert value to CVarArg type

The following code produced a cast error

let val: UInt128 = UInt128.max
String.init(format: "0x%0X", val as! CVarArg ) 

Do you have any advice on how to solve this problem?

Unable to add with package manager

I've added this line in dependencies
.package(url: "https://github.com/Jitsusama/UInt128.git", from: "0.8.0")

but I'm getting this error when resolving a package:
error: the package dependency graph could not be resolved; unable to find any available tag for the following requirements: https://github.com/Jitsusama/UInt128.git @ 0.8.0..<1.0.0

I checked tags and both are there "0.8.0" and "v0.8.0", a bit strange ... what could be the issue?

Is UInt128 Ready for a Version Bump?

I am wondering how everyone feels about doing a version bump on UInt128? If we were to do one, does everyone feel that it is ready for a 1.0.0 release? I'm also not up to date on Swift packaging. If I were to just push a tag for a new release, would that be enough for all of the cool package managers to find it, or should something else happen?

@gongzhang & @adamnemecek; I'm especially interested to hear your thoughts on this.

does not work with code 15 out of the box.

I got:

image

โ€ข Failed to resolve dependencies Dependencies could not be resolved because 'uint128' contains incompatible tools version (3.1.0) and root depends on 'uint1...

I haver to force to master.

Cocoapods support

Hey! Thanks for the tool.
Could you add a Podspec for your library?

Not correct work: significantBits

let number = UInt128(4294967294)

//expected: number.significantBits == 31
//actually: number.significantBits == 32

quick fix:

--- significantBitCount += 1
+++ significantBitCount += UInt128(bitsToWalk & 1) 

Xcode 9.0 beta build error

error message:

/Volumes/dev2/UInt128/Sources/UInt128.swift:542:1: Type 'UInt128' does not conform to protocol 'BinaryInteger'
/Volumes/dev2/UInt128/Sources/UInt128.swift:542:1: Type 'UInt128' does not conform to protocol 'BinaryInteger'
/Volumes/dev2/UInt128/Sources/UInt128.swift:542:1: Type 'UInt128' does not conform to protocol 'Numeric'
/Volumes/dev2/UInt128/Sources/UInt128.swift:347:21: Binary operator '&+' cannot be applied to operands of type 'UInt128' and 'Int'
/Volumes/dev2/UInt128/Sources/UInt128.swift:354:21: Binary operator '&-' cannot be applied to operands of type 'UInt128' and 'Int'
/Volumes/dev2/UInt128/Sources/UInt128.swift:368:25: Binary operator '&-' cannot be applied to two 'UInt128' operands
/Volumes/dev2/UInt128/Sources/UInt128.swift:370:21: Binary operator '&+' cannot be applied to two 'UInt128' operands
/Volumes/dev2/UInt128/Sources/UInt128.swift:673:69: Binary operator '&+' cannot be applied to two 'UInt128' operands

UInt128 to String conversions are slow

UInt128 -> String conversions are 50x slower than UInt64 native.

Here is an example test:

class PerformanceTests : XCTestCase {
    func testStringPerformance64() {
        let value: UInt64 = 17434549027881090559
        measure {
            // takes 1.3 seconds
            for _ in 0..<100 {
                _ = String(value, radix: 16)
            }
        }
    }

    func testStringPerformance128() {
        let value = UInt128(upperBits: 17434549027881090559, lowerBits: 18373836492640810226)
        measure {
            // takes 78 seconds
            for _ in 0..<100 {
                _ = String(value, radix: 16)
            }
        }
    }
}

One workaround could be to fix this only for radix 16. This strategy could be expanded to radix 2, 4, 8 & 32. Should we consider a PR like this?

    internal func _valueToString(radix: Int = 10, uppercase: Bool = true) -> String {
        precondition((2...36) ~= radix, "radix must be within the range of 2-36.")
        // Simple case.
        if self == 0 {
            return "0"
        }

        // Will store the final string result.
        var result = String()

        // workaround for fast HEX output
        if radix == 16 {
            let lowerString = String(value.lowerBits, radix: radix)
            if value.upperBits == 0 {
                result = lowerString
            }
            else {
                result = String(value.upperBits, radix: radix)
                result.append(String(repeating: "0", count: 16 - lowerString.count))
                result += lowerString
            }
            return result
        }

        // ... rest of the existing solution here

This improves the speed by a factor of 50, but for radix 16 only.

Bump Version Number to 0.9.0

This issue is a reminder that I need to bump the version number up to 0.9.0 since we've added Codable support to the library.

No build scheme for iOS platform

Because no build scheme for iOS platform, project depend UInt128 with Carthage will produce following error

Module file's minimum deployment target is ios11.0 v11.0

Needs Test Cases

Perhaps a few tests of the boundary conditions would give people more faith in the project?

UInt256

Hey Joel,

If I wanted to implement UInt256, would I essentially just duplicate your work with a project with UInt128 in it and double all the 64 values to 128?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.