fix: randomFloatFrom now correctly stays in range
This commit is contained in:
parent
19577eca8c
commit
a67a36decb
1 changed files with 4 additions and 2 deletions
|
|
@ -1,3 +1,5 @@
|
||||||
|
/* jshint strict: false */
|
||||||
|
|
||||||
// TODO: Inhalte angleichen nach Zusammenfassung von app.js und function.js.
|
// TODO: Inhalte angleichen nach Zusammenfassung von app.js und function.js.
|
||||||
// Benennung und Beschreibungen verbessern.
|
// Benennung und Beschreibungen verbessern.
|
||||||
|
|
||||||
|
|
@ -424,10 +426,10 @@ function randomIntFrom(min, max, pos = 0) {
|
||||||
return Math.floor((Math.random() * (max - min + 1) + min) / pos) * pos;
|
return Math.floor((Math.random() * (max - min + 1) + min) / pos) * pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
function randomFloatFrom(min, max, dec = 0) {
|
function randomFloatFrom(min, max, dec = 1) {
|
||||||
dec = Math.pow(10, dec);
|
dec = Math.pow(10, dec);
|
||||||
|
|
||||||
return Math.round((Math.random() * (max - min + 1) + min) * dec) / dec;
|
return Math.round((Math.random() * (max - min) + min) * dec) / dec;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue