Skip to content

Commit 6426388

Browse files
authored
Merge pull request #1 from ThisIsMissEm/patch-1
Fix float errors
2 parents 37c6bb0 + 4580e9e commit 6426388

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/index.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class Cashify {
4444
}
4545

4646
/**
47-
* @param {number} amount Amount of money you want to convert
47+
* @param {number} amount Amount of money you want to convert (in decimal, e.g., $1 = 1.00)
4848
* @param {object} options Conversion options
4949
* @param {string} options.from Currency from which you want to convert
5050
* @param {string} options.to Currency to which you want to convert
@@ -58,12 +58,12 @@ class Cashify {
5858
return amount;
5959
}
6060

61-
return amount * getRate({base, rates, from, to});
61+
return (amount * 100) * getRate({base, rates, from, to}) / 100;
6262
}
6363
}
6464

6565
/**
66-
* @param {number} amount Amount of money you want to convert
66+
* @param {number} amount Amount of money you want to convert (in decimal, e.g., $1 = 1.00)
6767
* @param {object} options Conversion options
6868
* @param {string} options.from Currency from which you want to convert
6969
* @param {string} options.to Currency to which you want to convert
@@ -77,7 +77,7 @@ const convert = (amount: number, {from, to, base, rates}: Options): number => {
7777
return amount;
7878
}
7979

80-
return amount * getRate({base, rates, from, to});
80+
return (amount * 100) * getRate({base, rates, from, to}) / 100;
8181
};
8282

8383
export {

0 commit comments

Comments
 (0)