6 kyu
A floating-point system
65 of 230g964
Description:
A floating-point number can be represented as mantissa * radix ^ exponent
(^ is raising radix to power exponent).
In this kata we will be given a positive floating-point number aNumber
and we want to decompose it into a positive integer mantissa
composed of a given number of digits (called digitsNumber
) and of an exponent
.
Example:
aNumber = 0.06
If the number of digits asked for the mantissa
is digitsNumber = 10
one can write
aNumber : 6000000000 * 10 ^ -11
the exponent in this example est -11
.
Task
The function mantExp(aNumber, digitsNumber)
will return aNumber
in the form of a string: "mantissaPexponent" (concatenation of "mantissa", "P", "exponent"). So:
Examples:
mantExp(0.06, 10) returns "6000000000P-11".
mantExp(72.0, 12) returns "720000000000P-10"
mantExp(1.0, 5) returns "10000P-4"
mantExp(123456.0, 4) returns "1234P2"
Notes:
- In some languages
aNumber
could be given in the form of a string:mantExp("0.06", 10) returns "6000000000P-11".
- 1 <= digitsNumber <= 15
- 0 < aNumber < 5.0 ^ 128
- Please ask before translating
Fundamentals
Similar Kata:
Stats:
Created | Dec 16, 2019 |
Published | Dec 16, 2019 |
Warriors Trained | 1213 |
Total Skips | 81 |
Total Code Submissions | 3038 |
Total Times Completed | 230 |
Java Completions | 65 |
Kotlin Completions | 18 |
Shell Completions | 3 |
Ruby Completions | 20 |
Python Completions | 123 |
Rust Completions | 17 |
Total Stars | 28 |
% of votes with a positive feedback rating | 80% of 69 |
Total "Very Satisfied" Votes | 49 |
Total "Somewhat Satisfied" Votes | 12 |
Total "Not Satisfied" Votes | 8 |
Total Rank Assessments | 5 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 8 kyu |