Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Float from std package math/big #767

Closed
wienczny opened this issue Aug 15, 2016 · 7 comments
Closed

Support for Float from std package math/big #767

wienczny opened this issue Aug 15, 2016 · 7 comments

Comments

@wienczny
Copy link

Currently "big" types from c* are mapped using "gopkg.in/inf.v0". Please add support for the std library math/big

@wienczny wienczny changed the title Support for Float and Int from std package math/big Support for Float from std package math/big Aug 15, 2016
@Zariel
Copy link
Contributor

Zariel commented Aug 24, 2016

Any particular reason? The decimal type in Cassandra are infinite precision decimals which are encoded with a scale and an unscaled part, as far as I am aware the math/big package does not support scaled/unscaled decimals.

@wienczny
Copy link
Author

I need to convert to and from a swagger model. The model is generated using go-swagger which converts swagger "decimal numbers" to float64. The problem is that there is no easy conversion between those two.

@Zariel
Copy link
Contributor

Zariel commented Aug 24, 2016

Are those floating point numbers or arbitrary precision decimals?

@wienczny
Copy link
Author

Those values are regular javascript floating point numbers on the wire. I'm using java.lang.BigDecimal for calculations the client side though

@Zariel
Copy link
Contributor

Zariel commented Aug 24, 2016

Then your losing precision over the wire, gopkg.in/inf.v0 provides types which are compatible with java.lang.BigDecimal

@wienczny
Copy link
Author

You are right. That's why I don't want to loose more precision converting values. Maybe new types will be added with OAI/OpenAPI-Specification#607

@Zariel
Copy link
Contributor

Zariel commented Sep 13, 2016

There is a proposal to a big decimal type to the standard library see golang/go#12127 but that wont solve the issue of the incompatible types you are encountering. I would recommend converting them to strings or such and then converting back to the decimal type. Unless you have any suggestions I don't see how to implement the decimal type in Cassandra with the types in math/big.

@Zariel Zariel closed this as completed Sep 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants