Crate normalize_css_z

source ·
Expand description

Normalize a CSS z-index to an f32 floating-point number between 0.0 and 1.0.

Theoretically, this is not entirely feasible because we can generate only 2^23 (subnormal) * 127 (normal) = 1065353216 distinct floating-point numbers in this range.

Therefore, please use this understanding the inherent limitations.

To begin with a practical approach, let’s cover these ranges of z-index values:

  • [ 1879048192, 2147483647]
  • [ -268435456, 268435455]
  • [-2147483647, -1887436800]

| upper | middle | lower | |—––|––––|—––| | 32 | 64 | 31 |

This should suffice for most use cases.

Later, I aim to expand this to allow for customizable ranges, but for now, this is adequate.

Functions