Hex Percentage Calculator
Find what percentage one hex value is of another — useful for reading alpha channels, PWM duty cycles, and other byte values expressed as a fraction of their maximum.
How to Calculate a Hex Percentage
Convert both hex values to decimal. Divide the "part" value by the "whole" value, multiply by 100, and that's the percentage — the exact same formula used for decimal percentages, just with hex-formatted inputs.
Hex Percentage Example, Step by Step
80 is 50.20% of FF
0x80 is what percent of 0xFF? -> 50.20%
80 hex = 128 decimal FF hex = 255 decimal 128 / 255 = 0.50196... 0.50196... x 100 = 50.20%
| Step | Description | Result |
|---|---|---|
| Convert 80 | 80 (hex) = 128 (decimal) | 128 |
| Convert FF | FF (hex) = 255 (decimal) | 255 |
| Divide and multiply by 100 | 128 / 255 x 100 = 50.196... | 50.20% |
0x80 out of 0xFF is a common one to recognize — it's almost exactly the halfway point of a single byte, which is why 0x80 is frequently used as a 'roughly 50%' value in code.
Common Mistakes With Hex Percentages
- Dividing the whole by the part instead of the part by the whole, inverting the result.
- Forgetting to convert both values to decimal before dividing.
- Expecting a clean whole-number percentage — most hex fractions don't land exactly on one.
Frequently Asked Questions
How do you calculate what percentage one hex value is of another?
Convert both to decimal, divide the part by the whole, and multiply by 100. 0x80 out of 0xFF is 128 / 255 x 100, which rounds to 50.20%.
Why does the answer have decimal places instead of a whole percentage?
Most hex fractions don't land on an exact whole percentage — this calculator computes to 2 decimal places using scaled integer math (not floating point), so the result is precisely rounded rather than approximated.
Where does this come up with real hex values?
Alpha channel bytes (0x80 out of 0xFF is roughly 50% opacity), PWM duty cycles in embedded systems, and volume or brightness levels that are stored as a single byte out of a maximum.
What if I enter 0 as the whole value?
The calculator flags it as an error, since dividing by zero has no defined percentage.
Can the percentage be over 100%?
Yes — if the first value is larger than the second, the result will be over 100%, the same as with decimal percentages.
Is the rounding here truncated or rounded to nearest?
Rounded to nearest — 128/255 is 50.196...%, which this calculator correctly rounds to 50.20%, not truncated down to 50.19%.