Crate normalize_css_z

source ·
Expand description

Normalize a CSS z-index to an f32 floating-point number between 0.0 and 1.0. (not quite…)

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

And, the best part is that we only get a handful of precise numbers. Specifically, this crate can generate 67,108,865 unique floating-point numbers between 0.0 and 1.0, which should be more than sufficient for most use cases (hopefully).

Supported ranges of z-indexes

| upper                    | middle                  | lower                      |
| ------------------------ | ----------------------- | -------------------------- |
| [2130706432, 2147483647] | [-16777216, 16777216-1] | [-2147483647, -2130706431] |

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

Functions