diff options
author | Minteck <contact@minteck.org> | 2021-12-21 16:52:28 +0100 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2021-12-21 16:52:28 +0100 |
commit | 46e43f4bde4a35785b4997b81e86cd19f046b69b (patch) | |
tree | c53c2f826f777f9d6b2d249dab556feb72a6c3a6 /src/node_modules/chance/docs/basics/floating.md | |
download | langdetect-46e43f4bde4a35785b4997b81e86cd19f046b69b.tar.gz langdetect-46e43f4bde4a35785b4997b81e86cd19f046b69b.tar.bz2 langdetect-46e43f4bde4a35785b4997b81e86cd19f046b69b.zip |
Commit
Diffstat (limited to 'src/node_modules/chance/docs/basics/floating.md')
-rw-r--r-- | src/node_modules/chance/docs/basics/floating.md | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/node_modules/chance/docs/basics/floating.md b/src/node_modules/chance/docs/basics/floating.md new file mode 100644 index 0000000..623e40c --- /dev/null +++ b/src/node_modules/chance/docs/basics/floating.md @@ -0,0 +1,44 @@ +# floating + +```js +// usages +chance.floating() +chance.floating({ fixed: 7 }) +chance.floating({ min: 0, max: 100 }) +``` +<p class="pullquote">I wanted to use float or double as the method name but both are JS reserved words even though they aren't really used...</p> + +Return a random floating point number. + +```js +chance.floating(); +=> -211920142886.5024 +``` + +By default it will return a fixed number of at most 4 digits after the decimal. + +Note: *at most* 4 digits. This because, unless we returned trailing zeroes +(which aren't allowed on the JavaScript float) we can't guarantee 4 digits after +the decimal. So if random chance comes back with `82383854.2000` then +`82383854.2` is what will be returned. + +To retrieve a set number of fixed digits after the decimal, provide it as an option. + +```js +chance.floating({ fixed: 7 }); +=> -749512327.7447168 +``` + +As with other number functions, can include a min and/or max. + +```js +chance.floating({ min: 0, max: 100 }); +=> 31.9021 +``` + +Or combine them. + +```js +chance.floating({ min: 0, max: 100, fixed: 8 }); +=> 45.92367599 +``` |