-
-
Notifications
You must be signed in to change notification settings - Fork 975
change default precision of faker.number.float #1655
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
Comments
I was thinking we could add a new method like The current implementation of this could use a new method on Mersenne, e.g.
|
Other alternative ideas
|
@matthewmayer Do explicitly need a max precision float or do you just need more than 2 fractional digits? |
Doesn't have to be fully max precision. In reality for any real-world use case e.g. in #1654 5 or 6 digits is usually more than enough. |
Having a few more decimal digits from float (e.g. 6) aligns with my expectation regarding that method so I'm fine with it. What do the others think? |
Please note that we loose precision due to the math in faker.number.float |
Also given the way Mersenne twister works you're only going to get 2^32 possible values even though there are an way more possible float values than that. I don't think the precise precision matters that much as long as it's considerably smaller than any reasonable weight value. If you care that much about precision and error values, you are almost certainly not going to use the JavaScript Number class |
Is |
Just to clarify, are you talking about modifying the default precision of faker.number.float or adding a new method for generating float values? |
Modifying the existing. I assume that the current percentage result might be useful for some as well, so we could theoretically introduce a new method/alias with the old precision as default, but thats optional for me. |
Cool I agree. The current behavior was somewhat surprising to me. If we change the default then in most cases if you want a fixed number of decimal places you would be much better served by doing faker.number.float().toFixed(2) |
Maybe open a new issue for that (max precision float)?
Originally posted by @ST-DDT in #1654 (comment)
The text was updated successfully, but these errors were encountered: