Шаблон:Hexdigits2/doc

Мавод аз Википедиа — донишномаи озод

The Template:Hexdigits2 shows the 2-digit hexadecimal equivalent of a number from 0-255, ranging from "00" to "FF". It is intended, primarily, to encode hex color codes for the RGB color model (red/green/blue levels), such as with a span-tag: <span style="background:#D2D2D2; color:#4C01FF">.

Usage:    {{hexdigits2|254}}   gives: FE
{{hexdigits2|240}}   gives: F0
{{hexdigits2|11}}   gives: 0B

Performance considerations[вироиши манбаъ]

To streamline operation, the template uses a rapid binary tree to decide which hexadecimal digits match the value of the base ten number, rather than use #switch functions with more comparisons. The algorithm allows the template to execute at over 350 numbers per second, but only as 2-digit hex values. Larger numbers > 255 will be truncated to 2 digits, in the range F0 to FF, with the last digit modulo 16.

See also[вироиши манбаъ]