An open API service providing package, version and dependency metadata of many open source software ecosystems and registries.

Top 6.4% on proxy.golang.org
Top 0.4% dependent packages on proxy.golang.org
Top 0.5% dependent repos on proxy.golang.org
Top 1.8% docker downloads on proxy.golang.org

proxy.golang.org : github.com/thomaso-mirodin/intmath

Package intmath provides a simple integer math library. The standard Go math library uses the float64 type for everything. This often requires casting both input and result, resulting in more verbose and (possibly) slower code. This library aims to extend the Go math library by providing math packages for the int, uint, int32, uint32, int64 and uint64 types. The intmath package itself is just a dummy package used for documentation, testing and benchmarking - the real library is in the subpackages. Import the relevant type to use math functions tailored to that type. Note that the dedicated FPU in your computer can be so fast that casting to and from float64 would be faster than using integer math. In other words, the standard math library can in theory outperform these libraries despite repeated casting to and from float64. Similarly, some code in u64 and i64 may be optimised to run faster on 32bit systems, at a minor cost for 64bit systems. All else being equal, the code in the library will favour this behaviour (see for example the u64.Log2 source). Benchmarks are included so you can easily test the differences for yourself. They assume a uniform distribution of input. Not all math functions will be copied, as not all of them make sense in an integer math context. At the moment, the following functions have been implemented: As a general rule, all functions take and return types matching the type of the library. Functions in u64 only take and return uint64, for example. Think of it as fake function overloading: the functions have the same name in every library, but the library name determines the type. Compare the following code snippets using the standard math library, a hypothetical library throwing all types in the same library, and this library: Note that the last example is the least verbose, yet it is immediately clear what the types of c, k and z are. If there ever will be exceptions to this general rule of input and return types the functions will be listed here and the reasoning behind making an exception will be explained in the documentation. As mentioned before, the speed of modern FPUs should not be underestimated. Benchmarking is advised to see if your system actually benefits form this library. To do this run go test: Some benchmarks also include alternate implementations for different functions. These might just be more effective on your architecture.

Registry - Source - Documentation - JSON
purl: pkg:golang/github.com/thomaso-mirodin/intmath
License: BSD-3-Clause
Latest release: about 9 years ago
First release: about 9 years ago
Namespace: github.com/thomaso-mirodin
Dependent packages: 136
Dependent repositories: 143
Stars: 2 on GitHub
Forks: 1 on GitHub
Docker dependents: 22
Docker downloads: 42,291
See more repository details: repos.ecosyste.ms
Last synced: 10 days ago

    Loading...
    Readme
    Loading...