GithubHelp home page GithubHelp logo

go-inf / inf Goto Github PK

View Code? Open in Web Editor NEW
45.0 4.0 16.0 37 KB

Package inf (type inf.Dec) implements "infinite-precision" decimal arithmetic.

Home Page: https://godoc.org/gopkg.in/inf.v0

License: Other

Go 100.00%
math mathematics decimal arithmetic go golang

inf's People

Contributors

speter 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

Watchers

 avatar  avatar  avatar  avatar

inf's Issues

is it EOL ?

if it is EOL, do any other recommendations?

handle scale overflows

The below code produces a panic. This is happening because the scale passed is math.MinInt32. When quoRem (dec.go:311) tries to call exp10(-shift), it panics. Here shift is math.MinInt32, and when it takes the negative value of that, it ends up still with math.MinInt32 because of two's complement (see https://play.golang.org/p/9H2UtAurI7).

package main

import (
	"fmt"
	"math"

	inf "gopkg.in/inf.v0"
)

func main() {
	z := new(inf.Dec)
	x := inf.NewDec(1, 0)
	y := inf.NewDec(1, 0)
	z.QuoRound(x, y, math.MinInt32, inf.RoundHalfUp)
	fmt.Println(z)
}

Panics with:

panic: runtime error: index out of range

goroutine 1 [running]:
panic(0x4a91a0, 0xc42000a150)
	/usr/local/go/src/runtime/panic.go:500 +0x1a1
gopkg.in/inf%2ev0.exp10(0x80000000, 0x0)
	/go/src/gopkg.in/inf.v0/dec.go:393 +0x52
gopkg.in/inf%2ev0.(*Dec).quoRem(0xc420013020, 0xc420012f60, 0xc420012fc0, 0x180000000, 0xc42000eb00, 0xc42000eb20, 0x482186, 0x4a1260, 0x1)
	/go/src/gopkg.in/inf.v0/dec.go:311 +0x595
gopkg.in/inf%2ev0.(*Dec).quo(0xc420012f30, 0xc420012f60, 0xc420012fc0, 0x51a1e0, 0xc42000a2f4, 0x51a560, 0xc42000a3c0, 0x1)
	/go/src/gopkg.in/inf.v0/dec.go:264 +0x12b
gopkg.in/inf%2ev0.(*Dec).QuoRound(0xc420012f30, 0xc420012f60, 0xc420012fc0, 0x80000000, 0x51a560, 0xc42000a3c0, 0x0)
	/go/src/gopkg.in/inf.v0/dec.go:257 +0xa1
main.main()
	/go/src/gopkg.in/m.go:14 +0xb1
exit status 2

Please clarify license

Just like in the similar issue go-gcfg/gcfg#1
ambiguity of LICENSE scope may become a problem for packaging and distributing of this module in Debian. We've just had another package with similar problem rejected... Please advise.

Go 1.10: rounder_example_test.go:34: Println arg list ends with redundant newline

c7d99f8 does not pass unit tests with Go 1.10. At least:

+ GOPATH=/builddir/build/BUILD/inf-c7d99f84517584483b3d800924f7468c411de442/_build:/usr/share/gocode
+ go test -buildmode pie -compiler gc -ldflags '-extldflags '\''-Wl,-z,relro  '\'''
# gopkg.in/inf.v0_test
./rounder_example_test.go:34: Println arg list ends with redundant newline
FAIL    gopkg.in/inf.v0 [build failed]

Why does this REPO import gopkg.in/inf.v0

The README.md needs a clarification so we aren't lost in almost-self-reference hell. The initial page for this REPO reads,

Package inf (type inf.Dec) implements "infinite-precision" decimal arithmetic. https://godoc.org/gopkg.in/inf.v0

but the package is called inf not inf.v0 inside go-inf not gopkg.in. It seems like this package is NOT what people want. It seems like we need to go to https://gopkg.in/inf.v0 and following the link to https://github.com/go-inf/inf/tree/v0.9.1. But if you build this code it still imports "gopkg.in/inf.v0 so it won't build anyway.

What is the point of all this nonsense? Where is the code that satisfies:

package inf_test

import (
	"math/big"
	"testing"

	"gopkg.in/inf.v0"
)

inside say inf/rounder_test.go ? Are we supposed to clone https://github.com/go-inf/inf/tree/v0.9.1 and put it into src tree as .../src/gopkg.in/inf.v0 Why break the mold as this isn't how all other packages work?

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.