Value to Percentage Converter
Convert numbers, dates, times, file sizes, mass, and lengths to percentage values. Supports multiple units with configurable decimal precision.
About
Percentage computation across heterogeneous units is error-prone. Converting 326.25 m against 5 km requires correct normalization to a common base before division. Mixing up 1024-based file size units with 1000-based prefixes produces silently wrong results in storage capacity reports. This tool normalizes six distinct domains - raw numbers, dates, time durations, file sizes, lengths, and mass - to their canonical base units before applying the ratio formula vT × 100. All conversion factors follow SI definitions and common conventions: file sizes use binary prefixes (1 KB = 1024 B), lengths use the international yard-pound agreement (1 yd = 0.9144 m), and months approximate to 30.4167 days from 36512.
Limitation: date calculations assume Gregorian calendar and do not account for leap-second corrections. Time duration tokens use fixed averages for months and years. The tool truncates results to the specified decimal places without banker's rounding. For financial or scientific reporting requiring IEEE 754 compliance, verify edge cases independently.
Formulas
The core operation across all six modes reduces to a single ratio scaled to 100:
Where P = percentage result, V = the value (numerator) normalized to base units, and T = the total (denominator) normalized to the same base units. The result is truncated to d decimal places where d defaults to 2.
For the Dates mode, the formula expands to a positional interpolation:
Where ttarget, tstart, and tend are Unix epoch timestamps in milliseconds obtained from JavaScript Date.parse.
For Time durations, the parser tokenizes input strings using the pattern: [value][unit] repeated (e.g., 3h2min30sec) or the colon-separated format HH:MM:SS.ms. Each token is multiplied by its millisecond factor and summed.
For Filesize, binary prefixes are used: 1 KB = 10241 B, 1 MB = 10242 B, and so on through YB at 10248.
Reference Data
| Domain | Unit | Symbol | Base Unit | Conversion Factor |
|---|---|---|---|---|
| Filesize | Byte | B | B | 1 |
| Filesize | Kilobyte | KB | B | 1024 |
| Filesize | Megabyte | MB | B | 1,048,576 |
| Filesize | Gigabyte | GB | B | 1,073,741,824 |
| Filesize | Terabyte | TB | B | 1.0995 × 1012 |
| Filesize | Petabyte | PB | B | 1.1259 × 1015 |
| Filesize | Exabyte | EB | B | 1.1529 × 1018 |
| Filesize | Zettabyte | ZB | B | 1.1806 × 1021 |
| Filesize | Yottabyte | YB | B | 1.2089 × 1024 |
| Length | Millimeter | mm | m | 0.001 |
| Length | Centimeter | cm | m | 0.01 |
| Length | Decimeter | dm | m | 0.1 |
| Length | Meter | m | m | 1 |
| Length | Kilometer | km | m | 1000 |
| Length | Foot | ft | m | 0.3048 |
| Length | Inch | in | m | 0.0254 |
| Length | Yard | yd | m | 0.9144 |
| Mass | Milligram | mg | g | 0.001 |
| Mass | Gram | g | g | 1 |
| Mass | Kilogram | kg | g | 1000 |
| Mass | Pound | lb | g | 453.592 |
| Mass | Ounce | oz | g | 28.3495 |
| Time | Millisecond | ms | ms | 1 |
| Time | Second | sec | ms | 1,000 |
| Time | Minute | min | ms | 60,000 |
| Time | Hour | h | ms | 3,600,000 |
| Time | Day | d | ms | 86,400,000 |
| Time | Week | w | ms | 604,800,000 |
| Time | Month | m | ms | 2,628,000,000 |
| Time | Year | y | ms | 31,536,000,000 |