https://github.com/cockroachdb/apd

Last synced: about 1 month ago

Repository metadata:

Arbitrary-precision decimals for Go


Owner metadata:


Committers metadata

Last synced: about 1 month ago

Total Commits: 263
Total Committers: 11
Avg Commits per committer: 23.909
Development Distribution Score (DDS): 0.259

Commits in past year: 4
Committers in past year: 2
Avg Commits per committer in past year: 2.0
Development Distribution Score (DDS) in past year: 0.25

Name Email Commits
Matt Jibson m****n@g****m 195
Nathan VanBenschoten n****n@g****m 44
Radu Berinde r****u@c****m 11
Daniel Theophanes k****s@g****m 3
David Eisenstat e****n@c****m 2
Oliver Tan o****n@c****m 2
Yevgeniy Miretskiy y****y@c****m 2
Gaylor Bosson gb@t****h 1
Josh Bleecher Snyder j****n@g****m 1
Matt Jibson m****n@c****m 1
Dale Hui d****i 1

Issue and Pull Request metadata

Last synced: about 1 month ago


Package metadata

go: github.com/cockroachdb/apd/v2

Package apd implements arbitrary-precision decimals. apd implements much of the decimal specification from the General Decimal Arithmetic (http://speleotrove.com/decimal/) description, which is refered to here as GDA. This is the same specification implemented by pythons decimal module (https://docs.python.org/2/library/decimal.html) and GCCs decimal extension. Panic-free operation. The math/big types don’t return errors, and instead panic under some conditions that are documented. This requires users to validate the inputs before using them. Meanwhile, we’d like our decimal operations to have more failure modes and more input requirements than the math/big types, so using that API would be difficult. apd instead returns errors when needed. Support for standard functions. sqrt, ln, pow, etc. Accurate and configurable precision. Operations will use enough internal precision to produce a correct result at the requested precision. Precision is set by a "context" structure that accompanies the function arguments, as discussed in the next section. Good performance. Operations will either be fast enough or will produce an error if they will be slow. This prevents edge-case operations from consuming lots of CPU or memory. Condition flags and traps. All operations will report whether their result is exact, is rounded, is over- or under-flowed, is subnormal (https://en.wikipedia.org/wiki/Denormal_number), or is some other condition. apd supports traps which will trigger an error on any of these conditions. This makes it possible to guarantee exactness in computations, if needed. SQL scan and value methods are implemented. This allows the use of Decimals as placeholder parameters and row result Scan destinations. apd has two main types. The first is Decimal which holds the values of decimals. It is simple and uses a big.Int with an exponent to describe values. Most operations on Decimals can’t produce errors as they work directly on the underlying big.Int. Notably, however, there are no arithmetic operations on Decimals. The second main type is Context, which is where all arithmetic operations are defined. A Context describes the precision, range, and some other restrictions during operations. These operations can all produce failures, and so return errors. Context operations, in addition to errors, return a Condition, which is a bitfield of flags that occurred during an operation. These include overflow, underflow, inexact, rounded, and others. The Traps field of a Context can be set which will produce an error if the corresponding flag occurs. An example of this is given below.

  • Homepage: https://github.com/cockroachdb/apd
  • Documentation: https://pkg.go.dev/github.com/cockroachdb/apd/v2#section-documentation
  • Licenses: Apache-2.0
  • Latest release: v2.0.2 (published over 5 years ago)
  • Last Synced: 2024-11-11T01:31:35.139Z (about 1 month ago)
  • Versions: 3
  • Dependent Packages: 2,321
  • Dependent Repositories: 2,074
  • Docker Downloads: 4,602,272,337
  • Rankings:
    • Docker downloads count: 0.056%
    • Dependent packages count: 0.09%
    • Dependent repos count: 0.178%
    • Average: 1.43%
    • Stargazers count: 2.654%
    • Forks count: 4.17%
go: github.com/cockroachdb/apd

Package apd implements arbitrary-precision decimals. apd implements much of the decimal specification from the General Decimal Arithmetic (http://speleotrove.com/decimal/) description, which is refered to here as GDA. This is the same specification implemented by pythons decimal module (https://docs.python.org/2/library/decimal.html) and GCCs decimal extension. Panic-free operation. The math/big types don’t return errors, and instead panic under some conditions that are documented. This requires users to validate the inputs before using them. Meanwhile, we’d like our decimal operations to have more failure modes and more input requirements than the math/big types, so using that API would be difficult. apd instead returns errors when needed. Support for standard functions. sqrt, ln, pow, etc. Accurate and configurable precision. Operations will use enough internal precision to produce a correct result at the requested precision. Precision is set by a "context" structure that accompanies the function arguments, as discussed in the next section. Good performance. Operations will either be fast enough or will produce an error if they will be slow. This prevents edge-case operations from consuming lots of CPU or memory. Condition flags and traps. All operations will report whether their result is exact, is rounded, is over- or under-flowed, is subnormal (https://en.wikipedia.org/wiki/Denormal_number), or is some other condition. apd supports traps which will trigger an error on any of these conditions. This makes it possible to guarantee exactness in computations, if needed. SQL scan and value methods are implemented. This allows the use of Decimals as placeholder parameters and row result Scan destinations. apd has two main types. The first is Decimal which holds the values of decimals. It is simple and uses a big.Int with an exponent to describe values. Most operations on Decimals can’t produce errors as they work directly on the underlying big.Int. Notably, however, there are no arithmetic operations on Decimals. The second main type is Context, which is where all arithmetic operations are defined. A Context describes the precision, range, and some other restrictions during operations. These operations can all produce failures, and so return errors. Context operations, in addition to errors, return a Condition, which is a bitfield of flags that occurred during an operation. These include overflow, underflow, inexact, rounded, and others. The Traps field of a Context can be set which will produce an error if the corresponding flag occurs. An example of this is given below.

  • Homepage: https://github.com/cockroachdb/apd
  • Documentation: https://pkg.go.dev/github.com/cockroachdb/apd#section-documentation
  • Licenses: Apache-2.0
  • Latest release: v1.1.0 (published over 6 years ago)
  • Last Synced: 2024-11-11T01:31:34.245Z (about 1 month ago)
  • Versions: 2
  • Dependent Packages: 1,368
  • Dependent Repositories: 26,502
  • Docker Downloads: 11,134,648
  • Rankings:
    • Dependent repos count: 0.036%
    • Dependent packages count: 0.115%
    • Docker downloads count: 0.619%
    • Average: 1.519%
    • Stargazers count: 2.654%
    • Forks count: 4.17%
go: github.com/cockroachdb/apd/v3

Package apd implements arbitrary-precision decimals. apd implements much of the decimal specification from the General Decimal Arithmetic (http://speleotrove.com/decimal/) description, which is refered to here as GDA. This is the same specification implemented by pythons decimal module (https://docs.python.org/2/library/decimal.html) and GCCs decimal extension. Panic-free operation. The math/big types don’t return errors, and instead panic under some conditions that are documented. This requires users to validate the inputs before using them. Meanwhile, we’d like our decimal operations to have more failure modes and more input requirements than the math/big types, so using that API would be difficult. apd instead returns errors when needed. Support for standard functions. sqrt, ln, pow, etc. Accurate and configurable precision. Operations will use enough internal precision to produce a correct result at the requested precision. Precision is set by a "context" structure that accompanies the function arguments, as discussed in the next section. Good performance. Operations will either be fast enough or will produce an error if they will be slow. This prevents edge-case operations from consuming lots of CPU or memory. Condition flags and traps. All operations will report whether their result is exact, is rounded, is over- or under-flowed, is subnormal (https://en.wikipedia.org/wiki/Denormal_number), or is some other condition. apd supports traps which will trigger an error on any of these conditions. This makes it possible to guarantee exactness in computations, if needed. SQL scan and value methods are implemented. This allows the use of Decimals as placeholder parameters and row result Scan destinations. apd has two main types. The first is Decimal which holds the values of decimals. It is simple and uses a big.Int with an exponent to describe values. Most operations on Decimals can’t produce errors as they work directly on the underlying big.Int. Notably, however, there are no arithmetic operations on Decimals. The second main type is Context, which is where all arithmetic operations are defined. A Context describes the precision, range, and some other restrictions during operations. These operations can all produce failures, and so return errors. Context operations, in addition to errors, return a Condition, which is a bitfield of flags that occurred during an operation. These include overflow, underflow, inexact, rounded, and others. The Traps field of a Context can be set which will produce an error if the corresponding flag occurs. An example of this is given below.

  • Homepage: https://github.com/cockroachdb/apd
  • Documentation: https://pkg.go.dev/github.com/cockroachdb/apd/v3#section-documentation
  • Licenses: Apache-2.0
  • Latest release: v3.2.1 (published over 1 year ago)
  • Last Synced: 2024-11-11T01:31:35.394Z (about 1 month ago)
  • Versions: 7
  • Dependent Packages: 305
  • Dependent Repositories: 384
  • Docker Downloads: 6,736,286
  • Rankings:
    • Dependent repos count: 0.352%
    • Dependent packages count: 0.569%
    • Docker downloads count: 0.994%
    • Average: 1.7%
    • Stargazers count: 2.573%
    • Forks count: 4.012%

Dependencies

go.mod go
  • github.com/pkg/errors v0.8.0
go.sum go
  • github.com/pkg/errors v0.8.0
.github/workflows/go.yml actions
  • actions/checkout v2 composite
  • actions/setup-go v2 composite
  • uraimo/run-on-arch-action v2.1.1 composite