bitburner-src/utils/helpers/roundToTwo.ts

10 lines
262 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) {
const leftShift: number = Math.round(parseInt(`${decimal}e+2`, 10));
return +(`${leftShift}e-2`);
}