Template talk:Hex2dec
Appearance
Lowercase can give different result
Resolved
– & we must accept wikimedia's limited thing/kingPlease compare:
{{hex2dec|A9}}
--> 169{{hex2dec|a9}}
--> 169{{hex2dec|0xA9}}
--> 169{{hex2dec|0xa9}}
--> 169
So when the "0x"-prefix is missing, the lowercase gives a different (and incorrect) result. So I put the disputed-tag on it. Other input might give the correct result (as I have noticed). Inputting a straight valid hex value like "a9" should be possible. -DePiep (talk) 19:01, 7 September 2010 (UTC)
- Template Template:Hex2rgb(edit talk links history) uses this one, and also has this error. Tagged & talked there too. -DePiep (talk) 10:22, 8 September 2010 (UTC)
- I fixed that one, I will see if I can fix this one. Plastikspork ―Œ(talk) 21:58, 10 September 2010 (UTC)
- Solved, somehow. The source of the problem is untouched! Hex2dec is a deep template (nesting about say 16 levels, innit). That is expensive, we only got 40 levels. But if it works, than let's go with it (and pray for Wikimedia to give us some string-parsing functions). -DePiep (talk) 22:18, 10 September 2010 (UTC)
- I was incorrect, and struck: this template is not solved. -DePiep (talk) 22:22, 10 September 2010 (UTC)
- Note that the documentation doesn't claim it works without the 0x prefix. So, I am not sure if this is "broken", or perhaps you just want the addition of another feature? I could certainly add some logic to test to see if the 0x prefix exists, but is that necessary? Plastikspork ―Œ(talk) 22:30, 10 September 2010 (UTC)
- Yes the doc doesn't promise lowercase. So? That's a programmers-excuse. Every hex user knows: A=a. So let's not blame an editor for not writing a hex value in uppercase (and even if so: at least give an error-message). Oh please, hex2dec should accept as many input as possible. No excuses between us, good programmers as we are. -DePiep (talk) 22:39, 10 September 2010 (UTC)
- Note that the documentation doesn't claim it works without the 0x prefix. So, I am not sure if this is "broken", or perhaps you just want the addition of another feature? I could certainly add some logic to test to see if the 0x prefix exists, but is that necessary? Plastikspork ―Œ(talk) 22:30, 10 September 2010 (UTC)
- I was incorrect, and struck: this template is not solved. -DePiep (talk) 22:22, 10 September 2010 (UTC)
- Solved, somehow. The source of the problem is untouched! Hex2dec is a deep template (nesting about say 16 levels, innit). That is expensive, we only got 40 levels. But if it works, than let's go with it (and pray for Wikimedia to give us some string-parsing functions). -DePiep (talk) 22:18, 10 September 2010 (UTC)
- I fixed that one, I will see if I can fix this one. Plastikspork ―Œ(talk) 21:58, 10 September 2010 (UTC)
Please re-read what I wrote. It claims to work for lowercase, but it does not claim to work without the 0x prefix. Thanks! Plastikspork ―Œ(talk) 22:41, 10 September 2010 (UTC)
- Yes I know it doesn't work for lc. That's what I protested. Once and for all: everyone is allowed to expect that it works with lc. That is what hex is about. Now stop repeating what the doc does not promise. Help making it behave as hexpected, or go away. No one needs a "I know why it doesn't function"-help. And here is the test again:
{{hex2dec|a9}}
--> 169. As every hex knows, that should be 169 decimal. -DePiep (talk) 01:01, 11 September 2010 (UTC)
- Please be calm.
- The problem seems to be an irregularity in the way some of the core parser functions work. as near as I can tell at the moment, what's happening is that the switch function is recognizing 0x and 0X as the start of a hexidecimal number and ignoring case in those cases for comparisons, but treating a9 and A9 as text strings and comparing them on a case sensitive basis. it's a knotty problem that I can't quite see my way through yet, but I'm pondering. --Ludwigs2 06:58, 11 September 2010 (UTC)
- ✓ ok, looks like I fixed it. plus, I think I may have reduced its resource footprint a bit. let's see if any problems crop up. --Ludwigs2 08:18, 11 September 2010 (UTC)
E7 wrong
{{hex2dec|E7}}
--> 231 OK, As we expect (23110=E716)
Now please look at this:
{{hex2dec|00D7}}
--> 215{{hex2dec|00E7}}
--> 231{{hex2dec|00F7}}
--> 247
These are neighbors in hex-language:
{{hex2dec|00E6}}
--> 230{{hex2dec|00E7}}
--> 231{{hex2dec|00E8}}
--> 232
Alikes:
{{hex2dec|00E7}}
--> 231{{hex2dec|01E7}}
--> 487{{hex2dec|02E7}}
--> 743{{hex2dec|06E7}}
--> 1767{{hex2dec|07E7}}
--> 2023{{hex2dec|08E7}}
--> 2279{{hex2dec|09E7}}
--> 2535{{hex2dec|0AE7}}
--> 2791{{hex2dec|0FE7}}
--> 4071
Another check:
{{hex2dec|00E7}}
--> 231{{hex2dec|0E7}}
--> 231{{hex2dec|E7}}
--> 231
- Anyone?
-DePiep (talk) 20:44, 10 September 2010 (UTC) Added more examples. -DePiep (talk) 20:59, 10 September 2010 (UTC)
- Ah, at I myself: the "E7" is read as "exponent" 7 etc. So 0 * 10^7 = zero.
- -DePiep (talk) 21:14, 10 September 2010 (UTC) (moved location)- DePiep (talk) 21:14, 10 September 2010 (UTC)
- Okay, this should be fixable. I will see what I can do. Plastikspork ―Œ(talk) 21:59, 10 September 2010 (UTC)