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

Convert string to floating point number,The last 0 is missing #298

Open
coverthesea opened this issue Oct 29, 2022 · 1 comment
Open

Comments

@coverthesea
Copy link

price, err := decimal.NewFromString("1.00")

priceFloat, _ := price.Float64()

the priceFloat is 1 ,not 1.00
I think it should be 1.00

@tgbv
Copy link

tgbv commented Nov 12, 2022

A float 1 is the same as 1.0, same as 1.00, same as 1.0000000, etc

If you need to keep the decimals, you're looking for priceFloat.StringFixedBank(2); where '2' is the nr of decimals to keep

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