Skip to content

Commit

Permalink
fix: convert to string for rounding
Browse files Browse the repository at this point in the history
  • Loading branch information
kate-deriv committed Nov 6, 2024
1 parent 7adf078 commit abea159
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/utils/common-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,14 @@ export const reactNodeToString = (reactNode: React.ReactNode): string => {
return string;
};

const toFixedWithoutRounding = (value: number, decimals: number) =>
Math.floor(Math.pow(10, decimals) * value) / Math.pow(10, decimals);
const toFixedWithoutRounding = (value: number, decimals: number) => {
const stringified_value = value.toString();
const result = stringified_value.slice(
0,
stringified_value.indexOf(".") + decimals + 1,
);
return Number(result);
};

export const getFormatValue = (
value: number | string,
Expand Down

0 comments on commit abea159

Please sign in to comment.