bitburner-src/utils/helpers/roundToTwo.ts
2021-05-01 03:17:31 -04:00

10 lines
268 B
TypeScript

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