Faker.js: How do I generate a random float with a set number of decimal places!?

Created on 24 Oct 2016  路  2Comments  路  Source: Marak/faker.js

Why no decimalPlaces option for random.number? What is precision used for?

Most helpful comment

I was just about to make a PR, then by trial and error and some logical deduction figured it out.

'random.number': {min: 1, max: 5, precision: 0.01}

All 2 comments

I now see that there is no such option, it always wraps result with Math.floor.
Please add random.float with min, max and decimalPlaces option ;)

I was just about to make a PR, then by trial and error and some logical deduction figured it out.

'random.number': {min: 1, max: 5, precision: 0.01}

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AlexMiroshnikov picture AlexMiroshnikov  路  4Comments

developdeez picture developdeez  路  5Comments

blackshady picture blackshady  路  4Comments

JeffBeltran picture JeffBeltran  路  5Comments

adoyle-h picture adoyle-h  路  3Comments