Skip to content
This repository has been archived by the owner on Jan 9, 2024. It is now read-only.

Commit

Permalink
Optimize random fluctuated computation
Browse files Browse the repository at this point in the history
Signed-off-by: Jérôme Benoit <[email protected]>
  • Loading branch information
Jérôme Benoit committed Jun 20, 2021
1 parent b410677 commit 97ef739
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/utils/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ export default class Utils {
if (fluctuationPercent === 0) {
return Utils.roundTo(staticValue, scale);
}
return Utils.getRandomFloatRounded(staticValue + staticValue * (fluctuationPercent / 100), staticValue - staticValue * (fluctuationPercent / 100), scale);
const fluctuationRatio = fluctuationPercent / 100;
return Utils.getRandomFloatRounded(staticValue * (1 + fluctuationRatio), staticValue * (1 - fluctuationRatio), scale);
}

static cloneObject<T>(object: T): T {
Expand Down

0 comments on commit 97ef739

Please sign in to comment.