Изменения

Перейти к: навигация, поиск

Шаблон:Str len/core

2297 байтов добавлено, 18:58, 16 декабря 2015
Новая страница: «{{#switch: {{{3|}}} | hundreds = <!-- 0xx-4xx, using linear search since most strings will probably be less than 100 bytes. --> {{#ifeq: x{{{1|}}} | x{{padleft…»
{{#switch: {{{3|}}}

| hundreds = <!-- 0xx-4xx, using linear search since most strings will probably be less than 100 bytes. -->
{{#ifeq: x{{{1|}}} | x{{padleft:{{{1|}}}| 100 }} <!--str >= x-->
| {{#ifeq: x{{{1|}}} | x{{padleft:{{{1|}}}| 200 }}
| {{#ifeq: x{{{1|}}} | x{{padleft:{{{1|}}}| 300 }}
| {{#ifeq: x{{{1|}}} | x{{padleft:{{{1|}}}| 400 }}
| 4
| 3
}}
| 2
}}
| 1
}}
| <!-- Don't return 0, since tens and ones don't want a leading 0 in parameter 2. -->
}}

| tens = <!-- x0x-x9x, using linear search for 0x-3x, binary search for 4x-9x, since most strings will probably be 0-39 bytes. -->
{{{2|}}}{{
#ifeq: x{{{1|}}} | x{{padleft:{{{1|}}}| {{{2|}}}10 }} <!--str >= x-->
| {{#ifeq: x{{{1|}}} | x{{padleft:{{{1|}}}| {{{2|}}}20 }}
| {{#ifeq: x{{{1|}}} | x{{padleft:{{{1|}}}| {{{2|}}}30 }}
| {{#ifeq: x{{{1|}}} | x{{padleft:{{{1|}}}| {{{2|}}}40 }}
| {{#ifeq: x{{{1|}}} | x{{padleft:{{{1|}}}| {{{2|}}}60 }}
| {{#ifeq: x{{{1|}}} | x{{padleft:{{{1|}}}| {{{2|}}}80 }}
| {{#ifeq: x{{{1|}}} | x{{padleft:{{{1|}}}| {{{2|}}}90 }}
| 9
| 8
}}
| {{#ifeq: x{{{1|}}} | x{{padleft:{{{1|}}}| {{{2|}}}70 }}
| 7
| 6
}}
}}
| {{#ifeq: x{{{1|}}} | x{{padleft:{{{1|}}}| {{{2|}}}50 }}
| 5
| 4
}}
}}
| 3
}}
| 2
}}
| 1
}}
| {{#if:{{{2|}}}|0}} <!-- Only return 0 if >=100, since ones don't want a leading 0 in parameter 2. -->
}}

| ones = <!-- xx0-xx9, using binary search. -->
{{{2|}}}{{
#ifeq: x{{{1|}}} | x{{padleft:{{{1|}}}| {{{2|}}}4 }} <!--str >= x-->
| {{#ifeq: x{{{1|}}} | x{{padleft:{{{1|}}}| {{{2|}}}6 }}
| {{#ifeq: x{{{1|}}} | x{{padleft:{{{1|}}}| {{{2|}}}8 }}
| {{#ifeq: x{{{1|}}} | x{{padleft:{{{1|}}}| {{{2|}}}9 }}
| 9
| 8
}}
| {{#ifeq: x{{{1|}}} | x{{padleft:{{{1|}}}| {{{2|}}}7 }}
| 7
| 6
}}
}}
| {{#ifeq: x{{{1|}}} | x{{padleft:{{{1|}}}| {{{2|}}}5 }}
| 5
| 4
}}
}}
| {{#ifeq: x{{{1|}}} | x{{padleft:{{{1|}}}| {{{2|}}}2 }}
| {{#ifeq: x{{{1|}}} | x{{padleft:{{{1|}}}| {{{2|}}}3 }}
| 3
| 2
}}
| {{#ifeq: x{{{1|}}} | x{{padleft:{{{1|}}}| {{{2|}}}1 }}
| 1
| 0
}}
}}
}}

}}