Number.prototype.toDecimal
Description:
Numbers in JavaScript can be turned into strings. For example, (123.456).toString()
gives you the string "123.456"
. But sometimes, numbers are so large or so small that the string returned is in a strange format called "scientific notation".
Here are some examples of scientific notation, as seen in JavaScript:
100 == 1e+2
0.01 == 1e-2
12.34 == 1.234e+1
0.000456 == 4.56e-4
The basic idea is that the "coefficient", to the left of "e" has its decimal place moved a number of places equal to the "exponent", to the right of "e". So:
4.56e-4
=======
4.56
^
v moved left 4
0.000456
1.234e+1
========
1.234
^
v moved right 1
12.34
That's all there is to it, really. But the problem is, JavaScript loves this scientific notation, even to the point that it can use it even when the number is in a manageable size. And there is no way of getting the original, full number as a string with any native method. And your job is to write one.
Write a method that can be called on any number that returns the number in all it's full, long-winded, memory-intensive string glory. ^^
Similar Kata:
Stats:
Created | Jan 7, 2014 |
Published | Jan 10, 2014 |
Warriors Trained | 409 |
Total Skips | 44 |
Total Code Submissions | 3921 |
Total Times Completed | 151 |
JavaScript Completions | 148 |
Total Stars | 20 |
% of votes with a positive feedback rating | 78% of 40 |
Total "Very Satisfied" Votes | 28 |
Total "Somewhat Satisfied" Votes | 6 |
Total "Not Satisfied" Votes | 1 |
Total Rank Assessments | 8 |
Average Assessed Rank | 5 kyu |
Highest Assessed Rank | 4 kyu |
Lowest Assessed Rank | 6 kyu |