-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #166 from Polygant/OC-249
Oc 249
- Loading branch information
Showing
9 changed files
with
74 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,27 @@ | ||
export default { | ||
methods: { | ||
getRegularNumber(x) { | ||
if (Math.abs(x) < 1.0) { | ||
let e = parseInt(x?.toString().split("e-")[1]); | ||
if (e) { | ||
x *= Math.pow(10, e - 1); | ||
x = | ||
"0." + | ||
new Array(e).join("0") + | ||
x.toString().substring(x < 0 ? 3 : 2); | ||
} | ||
} else { | ||
let e = parseInt(x?.toString().split("+")[1]); | ||
if (e > 20) { | ||
e -= 20; | ||
x /= Math.pow(10, e); | ||
x += new Array(e + 1).join("0"); | ||
} | ||
getRegularNumber(n) { | ||
let sign = +n < 0 ? "-" : "", | ||
toStr = n.toString(); | ||
if (!/e/i.test(toStr)) { | ||
return n; | ||
} | ||
return x; | ||
let [lead, decimal, pow] = n | ||
.toString() | ||
.replace(/^-/, "") | ||
.replace(/^([0-9]+)(e.*)/, "$1.$2") | ||
.split(/e|\./); | ||
return +pow < 0 | ||
? sign + | ||
"0." + | ||
"0".repeat(Math.max(Math.abs(pow) - 1 || 0, 0)) + | ||
lead + | ||
decimal | ||
: sign + | ||
lead + | ||
(+pow >= decimal.length | ||
? decimal + "0".repeat(Math.max(+pow - decimal.length || 0, 0)) | ||
: decimal.slice(0, +pow) + "." + decimal.slice(+pow)); | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters