Skip to content
Hex Calculator

Hex Percentage Calculator

Find what percentage one hex value is of another — useful for reading alpha channels, PWM duty cycles, and byte values expressed as a fraction of their max.

Percentage
50.20%

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%
StepDescriptionResult
Convert 8080 (hex) = 128 (decimal)128
Convert FFFF (hex) = 255 (decimal)255
Divide and multiply by 100128 / 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.

Where Hex Percentages Actually Come Up

Reading an Alpha Channel's Opacity

CSS and image formats store transparency as a single byte — converting that byte to a percentage tells you at a glance how opaque or transparent a color actually is.

0x80 / 0xFF = 50.20% opaque

Checking a PWM Duty Cycle

Motor controllers and LED dimmers set brightness or speed via PWM duty cycle, stored as a count out of a maximum — this converts that raw register value into the percentage it represents.

duty count / max count

Interpreting a Volume or Brightness Byte

Firmware that stores volume or screen brightness as a single byte (0-255) needs this same part-over-whole calculation to show the user a familiar percentage.

0xCC / 0xFF = 80.00%

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.

Why Use This Calculator Instead of Doing It by Hand

  • Uses scaled integer math, so the result is precisely rounded, not floating-point approximated
  • Runs entirely in your browser — nothing you type gets sent anywhere
  • Flags a zero whole value instead of returning a broken result
  • Handles percentages over 100% correctly, not just fractions of a whole

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%.

Why is 0x80 treated as roughly 50% instead of exactly 50%?

Because a byte's range (0-255) doesn't split evenly at its midpoint — the true 50% mark would be 127.5, which isn't a whole byte value, so 0x80 (128) is the closest whole-number approximation.

How do I read a PWM duty cycle from a hex register value?

Divide the register's current value by its maximum count and multiply by 100 — the same formula this calculator uses, since duty cycle is just a percentage of a maximum count.