mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-06 04:42:15 -05:00
Add optional precision argument to Base.formatFloat().
This commit is contained in:
parent
85d2700eb1
commit
80ffd41560
1 changed files with 4 additions and 2 deletions
|
@ -433,9 +433,11 @@ this.Base = Base.inject(/** @lends Base# */{
|
|||
* up to the amount of fractional digits.
|
||||
*
|
||||
* @param {Number} num the number to be converted to a string
|
||||
* @param {Number} [precision=5] the amount of fractional digits.
|
||||
*/
|
||||
formatFloat: function(num) {
|
||||
return (Math.round(num * 100000) / 100000).toString();
|
||||
formatFloat: function(num, precision) {
|
||||
precision = precision ? Math.pow(10, precision) : 100000;
|
||||
return (Math.round(num * precision) / precision);
|
||||
},
|
||||
|
||||
toFloat: function(str) {
|
||||
|
|
Loading…
Reference in a new issue