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

fix: Float functions should return the proper number of decimals #178

Merged
merged 1 commit into from
Oct 9, 2024

Conversation

mathieu-lemay
Copy link
Contributor

Description

Fix the float functions to return the proper number of decimals, based off of the maxDecimals argument. Prior to this fix, a random value was generated between 0 and maxDecimals and that was used as the decimal portion. This meant that values generated with maxDecimals=2, the decimal portion of all generated values would be either .0, .1 or .2, instead of there being 2 digits in the decimal portion. With the fix, values generated with maxDecimals=2 will have a decimal portion anywhere between .00 and .99, inclusively.

Missing tests were also added for Float, Float32 and Float64

Are you trying to fix an existing issue?

#177

Go Version

$ go version
go version go1.23.2 darwin/arm64

Go Tests

$ go test
2024/10/08 11:59:21 Error while requesting https://loremflickr.com/300/200 : request failed
2024/10/08 11:59:22 Error while creating a temp file: temp file creation failed
2024/10/08 11:59:22 Error while requesting https://randomuser.me : request failed
2024/10/08 11:59:22 Error while creating a temp file: temp file creation failed
PASS
ok      github.com/jaswdr/faker/v2      2.974s

@jaswdr jaswdr merged commit 8930726 into jaswdr:master Oct 9, 2024
13 of 14 checks passed
@mathieu-lemay mathieu-lemay deleted the fix-float branch November 22, 2024 23:14
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

Successfully merging this pull request may close these issues.

2 participants