bitburner-src/utils/helpers/roundToTwo.ts

9 lines
259 B
TypeScript
Raw Normal View History

/**
* Rounds a number to two decimal places.
* @param decimal A decimal value to trim to two places.
*/
export function roundToTwo(decimal: number) {
2018-07-10 07:11:18 +02:00
const leftShift: number = Math.round(parseFloat(`${decimal}e+2`));
return +(`${leftShift}e-2`);
}