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) = 1,065,353,216
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 25,165,825
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
| lower | middle | upper |
| --------------------------------- | ------------------------ | ------------------------------- |
| `-2_147_483_647..=-2_139_095_039` | `-4_194_303..=4_194_304` | `2_139_095_040..=2_147_483_647` |
Later, I aim to expand this to allow for customizable ranges, but for now, this should be adequate.