Problem 303. Convert Hard Drive marketing sizes to actual data sizes
Hard drive sizes are typically marketed using the decimal meaning of prefixes, whereas RAM uses binary meanings. For example:
A 10 GB hard drive (common only a few years ago) typically has 10,000,000,000 bytes 10 GB of RAM though is equal to 10,737,418,240 bytes
More information about this can be found here.
The problem is to take 2 inputs based upon decimal prefixes (a number representing size and a string representing the units) and output the equivalent size using binary prefixes, as seen below:
[100], 'MB' -> [95.4] [100], 'GB' -> [93.1]
Solution Stats
Problem Comments
-
4 Comments
could you provide some sort of indication as to the precision of said number?
please fix the errors in the solution check, or at least use consistent precision :/
My calculation suggests test 3 should have an answer of approximately 465.661, which is tricky to round to 465.5. (Not impossible, but not obvious/intuitive, and not consistent with answers specified for the other tests.) . . . Why was it like this? My guess is that all three answers were adapted directly from the three rows in the contemporary WP article linked to in the problem statement ( https://en.wikipedia.org/w/index.php?title=Hard_disk_drive&oldid=476051941#Units_of_storage_capacity ), to wit: * 100MB = first row; * 10GB = one tenth of second row; * 500GB = half of last row. This yields the peculiar rounding found in the Test Suite.
This problem is not correct at all. Test suite values were probably copied from Windows or somewhere in which they've rounded up the requested factor to 3 decimals. And even worse, sometimes this had been twice (at the factor, and after multiplying it by the alledged value).
Solution Comments
Show commentsProblem Recent Solvers67
Suggested Problems
-
7640 Solvers
-
1882 Solvers
-
296 Solvers
-
Are all the three given point in the same line?
414 Solvers
-
Given a matrix, return the last eigen value
219 Solvers
More from this Author39
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!