Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-8081-120121-

Fastest way to single hex digit => decimal

Name: Anonymous 2012-01-06 8:46

char hexchartodec_map[256] = {
        0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
        0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
        0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
        0,  1,  2,  3,  4,  5,  6,  7,  8,  9,  0,  0,  0,  0,  0,  0,
        0,  10, 11, 12, 13, 14, 15, 0,  0,  0,  0,  0,  0,  0,  0,  0,
        0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
        0,  10, 11, 12, 13, 14, 15, 0,  0,  0,  0,  0,  0,  0,  0,  0,
        0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
        0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
        0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
        0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
        0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
        0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
        0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
        0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
        0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
};

char hexchartodec(char i) {
        return hexchartodec_map[i];
}

Name: Anonymous 2012-01-06 8:51

Cool tip.

Name: Anonymous 2012-01-06 8:54

Implying table lookups will not rape my precious cache.
What are you, twelve?

Name: Anonymous 2012-01-06 10:38

Implying 256 bytes will rape anyone is cache
What is this, 1993?

Name: Anonymous 2012-01-06 10:53

That's how I implemented the popcnt instruction without the actual instruction.

Name: Anonymous 2012-01-06 11:04

hexToDec c = let x = ord c
  in ( (x .&. 0xf)      * ((x .&. 0x10) `shiftR` 4))
   + (((x .&. 0xf) + 9) * ((x .&. 0x40) `shiftR` 6))

Name: Anonymous 2012-01-06 11:05

It is not a matter of size, the fact that the table will end up in the data segment is enough to create misses if your program does something else than calling that function.

But you guys inspired me, so I attempted to fool around with the ascii table layout:

/**
 * Assuming c is in "0123456789abcdef", the result will be wrong otherwise.
 */
char hexchartodec(const char c) {
    char d = c - '0';
    /* This if kind of means c >= '@', the compiler can't assume that c < 128
     * (i also can't do that, but i don't give a fuck) */
    if (c & 0x40) { //c to avoid a pipeline stall (we will have more below)
        /* The point here is that ('1'+16='A')+32='a'.*/
        --d; //or maybe d = c - '1';
        d &= 0xf; /* from the alignment of the ascii table, the least
                   * significant decimal is ready */
        d += 10;
    }
    return d;
}


However I couldn't get rid of the if and there are stalls inside the if as well. I'm sure that someone has a completly obsfucated version that does better than mine.

Name: Anonymous 2012-01-06 11:22

>>7
How do you figure that

if (c & 40)

avoids a pipeline stall

Name: Anonymous 2012-01-06 11:52

>>8
c & 0x40 does not depend on the result of d = c- '0';
However that comment is a left over from earlier when I wrote if (d >= 10) where there would be stall because (almost)all instructions from d >=10 would directly or indirectly depend on the result of the previous statement whose instructions are stil being executed.

But i didn't avoided the cpu from doing a wrong prediction of the branch that the if will produce which is way worse than using d inside the if.

Anyways, when i say stall on that comments (and here) i say that there are c statements that depend on each other and the compiler and cpu most likely won't be able to avoid stalls because there are no other alternative for rescheduling the instructions that do that statements.

>>6 Sugestion is pretty neat (with repect to the cpu pipeline as well) and unless the cpu takes too long to multiply or your compiler and cpu are too dumb that might faster (and also looks kinda cool)

Name: Anonymous 2012-01-06 12:36

There's a really short on x86 using das.

Someone figured out a long time ago that das performs the comparison and subtraction of 6 automatically...

Name: Anonymous 2012-01-06 12:42

>>10
This highly underrated instruction is invalid in x86-64, so fuck it.

Name: Anonymous 2012-01-06 12:49

x86-64
I'd sooner go to MIPS than use that horrible extension of x86.

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2012-01-06 14:01

something like this(this is untested, i don;t have time for compiling right now)
#define decbyte(x) ((x&0x40)<<3)+((x&0x40)<<1)+(x&0xf))

Name: Anonymous 2012-01-06 14:04

>>13

BROKEN PIECE OF SHIT MACRO ABUSE


decbyte(x++);

Name: Anonymous 2012-01-06 14:13

>>6
GHC -S -O:
    movq %r14,%rax
    movq %rax,%rcx
    andq $64,%rcx
    sarq $6,%rcx
    movq %rax,%rdx
    andq $15,%rdx
    addq $9,%rdx
    imulq %rcx,%rdx
    movq %rax,%rcx
    andq $16,%rcx
    sarq $4,%rcx
    movq %rax,%rbx
    andq $15,%rbx
    imulq %rcx,%rbx
    addq %rdx,%rbx
    jmp *0(%rbp)


GCC -march=core2 -O4 -S (on a simple C conversion taking unsigned char and returning unsigned int):
    movzbl  %dil, %edi
    movl    %edi, %edx
    movl    %edi, %eax
    andl    $64, %edi
    andl    $16, %edx
    andl    $15, %eax
    sarl    $6, %edi
    sarl    $4, %edx
    imull   %eax, %edx
    addl    $9, %eax
    imull   %edi, %eax
    addl    %edx, %eax
    ret

Name: Anonymous 2012-01-06 14:16

>>15
GHC -fvia-c -S -O:
    movq    %r14, %rax
    movq    %r14, %rdx
    andl    $15, %edx
    movq    %r14, %rcx
    andl    $16, %ecx
    sarq    $4, %rcx
    imulq   %rdx, %rcx
    andl    $64, %eax
    sarq    $6, %rax
    addq    $9, %rdx
    imulq   %rax, %rdx
    leaq    (%rcx,%rdx), %rbx
    jmp *0(%rbp)

Name: Anonymous 2012-01-06 14:53

>>15,16
I can't read that retarded syntax, but multiplication? Really?

Name: Anonymous 2012-01-06 14:57

>>3
[quote]implying it looks anything up[/quote]

Name: Anonymous 2012-01-06 15:00

>>17
Trying to get rid of it with direct bit shitting.

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2012-01-06 15:13

this should be a couple cycles faster (x>>6+((x>>6)<<3))+(x&0xf)

Name: Anonymous 2012-01-06 15:17

>>19
My idea failed:
1. BT to set CF if flag is set.
2. SALC to set AL to 0xFF if CF set.
3. AND with something.
4. Repeat for other bit.
5. ADD.

Only problem is that SALC is undocumented and doesn't work in my processor (tried .byte 0xD6).

Name: Anonymous 2012-01-06 15:23

>>20
No one cares about you FrozenShit, take your shitty code elsewhere

Name: Anonymous 2012-01-06 17:54

DCL DD BINARY-NUMBER BIN(2);
DCL DD DECIMAL-NUMBER PKD(2);
DCL DD INPUT-CHARACTER CHAR(1);
XLATE INPUT-CHARACTER, INPUT-CHARACTER, 'ABCDEF', 'abcdef';
SCAN BINARY-NUMBER, '0123456789abcdef', INPUT-CHARACTER/ZER(=+2);
SUBN(S) BINARY-NUMBER, 1;:
CPYNV DECIMAL-NUMBER, BINARY-NUMBER;

Name: Anonymous 2012-01-06 21:23

>>21
Try sbb al, al. What processor is that, SALC has been there since 8086.

Name: Anonymous 2012-01-06 22:10

python version:

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>;.

def hex_char_to_decimal_value(h):
   if h == "0":
      return 0
   elif h == "1":
      return 1
   elif h == "2":
      return 2
   elif h == "3":
      return 3
   elif h == "4":
      return 4
   elif h == "5":
      return 5
   elif h == "6":
      return 6
   elif h == "7":
      return 7
   elif h == "8":
      return 8
   elif h == "9":
      return 9
   elif h == "A" or h == "a":
      return int(str(hex_char_to_decimal_value("1")) + str(hex_char_to_decimal_value("0")))
   elif h == "B" or h == "b":
      return int(str(hex_char_to_decimal_value("1")) + str(hex_char_to_decimal_value("1")))
   elif h == "C" or h == "c":
      return int(str(hex_char_to_decimal_value("1")) + str(hex_char_to_decimal_value("2")))
   elif h == "D" or h == "d":
      return int(str(hex_char_to_decimal_value("1")) + str(hex_char_to_decimal_value("3")))
   elif h == "E" or h == "e":
      return int(str(hex_char_to_decimal_value("1")) + str(hex_char_to_decimal_value("4")))
   elif h == "F" or h == "f":
      return int(str(hex_char_to_decimal_value("1")) + str(hex_char_to_decimal_value("5")))

Name: Anonymous 2012-01-06 22:19

>>25
Holy fuck, that is, by far, the worst program in this thread. You've obviously only used HLLs before and have no idea about optimisation. Please proceed to fuck yourself with a rake.

Name: Anonymous 2012-01-06 22:25

>>25
Having this posted, let's see some benchmarks.

Name: Anonymous 2012-01-06 22:31

/[^0-9A-Fa-f]/{c\
Input a valid hex digit, ``faggot.''
q
}
y/ABCDEF/abcdef/
/[a-f]/{
     s/^/1/
     y/abcdef/012345/
}

Name: Anonymous 2012-01-06 22:34

>>27
delan@pluto /tmp $ time echo -e 'from dicks25 import *\nfor i in range(100000):\n\thex_char_to_decimal_value("f")' | python

real    0m2.504s
user    0m2.430s
sys     0m0.070s
delan@pluto /tmp $ cc -o cocks1 cocks1.c
delan@pluto /tmp $ time ./cocks1

real    0m0.005s
user    0m0.000s
sys     0m0.000s


As you can see, the >>1 solution beats >>25 ridiculously for 100000 iterations. The >>1 solution takes less time than is accurately measurable by time, even. The cocks1.c file contains >>1 plus this line:

main() { int i; for (i++ < 100000) hexchartodec('F'); }

Name: Anonymous 2012-01-06 23:16

>>25
GPL

freedom at all costs scum

use MIT or BSD next time

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2012-01-07 2:02

benchmarks:
#include <stdio.h>
#define u1 unsigned char
#define u2 unsigned short
#define u4 unsigned int
#define u8 unsigned long long
#define s1 signed char
#define s2 signed short
#define s4 signed int
#define s8 signed long long
#define f2 short float
#define f4 float
#define f8 double
#define f10 long double
#define hexchartodec3(x) (((x>>6)+((x>>6)<<3))+(x&0xf))
u8 inline rdtsc(){__asm{RDTSC}}
char hexchartodec_map[256] = {
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  1,  2,  3,  4,  5,  6,  7,  8,  9,  0,  0,  0,  0,  0,  0,
            0,  10, 11, 12, 13, 14, 15, 0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  10, 11, 12, 13, 14, 15, 0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
    };

char hexchartodec(char i) {
        return hexchartodec_map[i];
}
char hexchartodec2(const char c) {
    char d = c - '0';
    /* This if kind of means c >= '@', the compiler can't assume that c < 128
     * (i also can't do that, but i don't give a fuck) */
    if (c & 0x40) { //c to avoid a pipeline stall (we will have more below)
        /* The point here is that ('1'+16='A')+32='a'.*/
        --d; //or maybe d = c - '1';
        d &= 0xf; /* from the alignment of the ascii table, the least
                   * significant decimal is ready */
        d += 10;
    }
    return d;
}
char  hexchartodec4(char i){
switch(i){//since multiple IFS in chain are retarded
case '0':;return 0;
case '1':;return 1;
case '2':;return 2;
case '3':;return 3;
case '4':;return 4;
case '5':;return 5;
case '6':;return 6;
case '7':;return 7;
case '8':;return 8;
case '9':;return 9;
case 'a':;return 10;
case 'b':;return 11;
case 'c':;return 12;
case 'd':;return 13;
case 'e':;return 14;
case 'f':;return 15;
default:return 0;
}


}
main(s4 argc,s1**argv){
u8 start=rdtsc(),end=rdtsc();//rdtsc_delay ~85 cycles;


s1 n1,n2,n3,n4;
//hexchartodec   
start=rdtsc();
n1=hexchartodec('1');
n2=hexchartodec('f');
n3=hexchartodec('d');
n4=hexchartodec('5');
end=rdtsc();
printf("hexchartodec(Post >>1) Chars:%d,%d,%d,%d time:%llu cycles\n",n1,n2,n3,n4,(end-start));
//hexchartodec2
start=rdtsc();
n2=hexchartodec2('1');
n1=hexchartodec2('f');
n4=hexchartodec2('d');
n3=hexchartodec2('5');
end=rdtsc();
printf("hexchartodec2(Post >>7) Chars:%d,%d,%d,%d time:%llu cycles\n",n2,n1,n4,n3,(end-start));
//hexchartodec3
start=rdtsc();
n3=hexchartodec3('1');
n2=hexchartodec3('f');
n4=hexchartodec3('d');
n1=hexchartodec3('5');
end=rdtsc();
printf("hexchartodec3(Post >>20) Chars:%d,%d,%d,%d time:%llu cycles\n",n3,n2,n4,n1,(end-start));
//hexchartodec4start=rdtsc();
n3=hexchartodec4('1');
n2=hexchartodec4('f');
n4=hexchartodec4('d');
n1=hexchartodec4('5');
end=rdtsc();
printf("hexchartodec4(Post >>25) Chars:%d,%d,%d,%d time:%llu cycles\n",n3,n2,n4,n1,(end-start));
/*
C:\Program Files\dmc8.50\dmc\dm\bin\code>hex
hexchartodec(Post >>1) Chars:1,15,13,5 time:325 cycles
hexchartodec2(Post >>7) Chars:1,15,13,5 time:1572 cycles
hexchartodec3(Post >>20) Chars:1,15,13,5 time:85 cycles
hexchartodec4(Post >>25) Chars:1,15,13,5 time:988060 cycles
*/


}

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2012-01-07 2:12

fixed the hexchartodec4
C:\Program Files\dmc8.50\dmc\dm\bin\code>hex
hexchartodec(Post >>1) Chars:1,15,13,5 time:414 cycles
hexchartodec2(Post >>7) Chars:1,15,13,5 time:1866 cycles
hexchartodec3(Post >>20) Chars:1,15,13,5 time:85 cycles
hexchartodec4(Post >>25) Chars:1,15,13,5 time:2566 cycles

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2012-01-07 2:13

#include <stdio.h>
#define u1 unsigned char
#define u2 unsigned short
#define u4 unsigned int
#define u8 unsigned long long
#define s1 signed char
#define s2 signed short
#define s4 signed int
#define s8 signed long long
#define f2 short float
#define f4 float
#define f8 double
#define f10 long double
#define hexchartodec3(x) (((x>>6)+((x>>6)<<3))+(x&0xf))
u8 inline rdtsc(){__asm{RDTSC}}
char hexchartodec_map[256] = {
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  1,  2,  3,  4,  5,  6,  7,  8,  9,  0,  0,  0,  0,  0,  0,
            0,  10, 11, 12, 13, 14, 15, 0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  10, 11, 12, 13, 14, 15, 0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
    };

char hexchartodec(char i) {
        return hexchartodec_map[i];
}
char hexchartodec2(const char c) {
    char d = c - '0';
    /* This if kind of means c >= '@', the compiler can't assume that c < 128
     * (i also can't do that, but i don't give a fuck) */
    if (c & 0x40) { //c to avoid a pipeline stall (we will have more below)
        /* The point here is that ('1'+16='A')+32='a'.*/
        --d; //or maybe d = c - '1';
        d &= 0xf; /* from the alignment of the ascii table, the least
                   * significant decimal is ready */
        d += 10;
    }
    return d;
}
char  hexchartodec4(char i){
switch(i){//since multiple IFS in chain are retarded
case '0':;return 0;
case '1':;return 1;
case '2':;return 2;
case '3':;return 3;
case '4':;return 4;
case '5':;return 5;
case '6':;return 6;
case '7':;return 7;
case '8':;return 8;
case '9':;return 9;
case 'a':;return 10;
case 'b':;return 11;
case 'c':;return 12;
case 'd':;return 13;
case 'e':;return 14;
case 'f':;return 15;
default:return 0;
}


}
main(s4 argc,s1**argv){
u8 start=rdtsc(),end=rdtsc();//rdtsc_delay ~85 cycles;


s1 n1,n2,n3,n4;
//hexchartodec   
start=rdtsc();
n1=hexchartodec('1');
n2=hexchartodec('f');
n3=hexchartodec('d');
n4=hexchartodec('5');
end=rdtsc();
printf("hexchartodec(Post >>1) Chars:%d,%d,%d,%d time:%llu cycles\n",n1,n2,n3,n4,(end-start));
//hexchartodec2
start=rdtsc();
n2=hexchartodec2('1');
n1=hexchartodec2('f');
n4=hexchartodec2('d');
n3=hexchartodec2('5');
end=rdtsc();
printf("hexchartodec2(Post >>7) Chars:%d,%d,%d,%d time:%llu cycles\n",n2,n1,n4,n3,(end-start));
//hexchartodec3
start=rdtsc();
n3=hexchartodec3('1');
n2=hexchartodec3('f');
n4=hexchartodec3('d');
n1=hexchartodec3('5');
end=rdtsc();
printf("hexchartodec3(Post >>20) Chars:%d,%d,%d,%d time:%llu cycles\n",n3,n2,n4,n1,(end-start));
//hexchartodec4start=rdtsc();
start=rdtsc();
n3=hexchartodec4('1');
n2=hexchartodec4('f');
n4=hexchartodec4('d');
n1=hexchartodec4('5');
end=rdtsc();
printf("hexchartodec4(Post >>25) Chars:%d,%d,%d,%d time:%llu cycles\n",n3,n2,n4,n1,(end-start));


}

Name: Anonymous 2012-01-07 2:49

And now for ISO STANDARD C...
#include <string.h>
#include <errno.h>
#include <ctype.h>
int hex2dec(int c) {
    static const char *s = "0123456789ABCDEF";
    char *p;
    if (p = memchr(s, toupper(c), 16))
        return p - s;
    else {
        errno = EDOM;
        return -1;
    }
}


Or alternatively...
#include <stdlib.h>
int hex2dec(int c) {
    char s[2] = {c, '\0'};
    return strtol(s, NULL, 16);
}


On invalid input, the first one returns -1 and sets errno to EDOM. On invalid input, the second one returns 0 and, as a POSIX extension, may set errno to EINVAL.

Name: Anonymous 2012-01-07 2:49

here we go again

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2012-01-07 3:00

/*
C:\Program Files\dmc8.50\dmc\dm\bin\code>hex
hexchartodec(Post >>1) Chars:1,15,13,5 time:584 cycles
hexchartodec2(Post >>7) Chars:1,15,13,5 time:1243 cycl
hexchartodec3(Post >>20) Chars:1,15,13,5 time:90 cycle
hexchartodec4(Post >>25) Chars:1,15,13,5 time:3772 cyc
hex2dec(Post >>34) Chars:1,15,13,5 time:5921 cycles
*/
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#define u1 unsigned char
#define u2 unsigned short
#define u4 unsigned int
#define u8 unsigned long long
#define s1 signed char
#define s2 signed short
#define s4 signed int
#define s8 signed long long
#define f2 short float
#define f4 float
#define f8 double
#define f10 long double
#define hexchartodec3(x) (((x>>6)+((x>>6)<<3))+(x&0xf))


int hex2dec(int c) {
    static const char *s = "0123456789ABCDEF";
    char *p;
    if (p = memchr(s, toupper(c), 16))
        return p - s;
    else {
        errno = EDOM;
        return -1;
    }
}




u8 inline rdtsc(){__asm{RDTSC}}
char hexchartodec_map[256] = {
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  1,  2,  3,  4,  5,  6,  7,  8,  9,  0,  0,  0,  0,  0,  0,
            0,  10, 11, 12, 13, 14, 15, 0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  10, 11, 12, 13, 14, 15, 0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
    };

char hexchartodec(char i) {
        return hexchartodec_map[i];
}
char hexchartodec2(const char c) {
    char d = c - '0';
    /* This if kind of means c >= '@', the compiler can't assume that c < 128
     * (i also can't do that, but i don't give a fuck) */
    if (c & 0x40) { //c to avoid a pipeline stall (we will have more below)
        /* The point here is that ('1'+16='A')+32='a'.*/
        --d; //or maybe d = c - '1';
        d &= 0xf; /* from the alignment of the ascii table, the least
                   * significant decimal is ready */
        d += 10;
    }
    return d;
}
char  hexchartodec4(char i){
switch(i){//since multiple IFS in chain are retarded
case '0':;return 0;
case '1':;return 1;
case '2':;return 2;
case '3':;return 3;
case '4':;return 4;
case '5':;return 5;
case '6':;return 6;
case '7':;return 7;
case '8':;return 8;
case '9':;return 9;
case 'a':;return 10;
case 'b':;return 11;
case 'c':;return 12;
case 'd':;return 13;
case 'e':;return 14;
case 'f':;return 15;
default:return 0;
}


}
main(s4 argc,s1**argv){
u8 start=rdtsc(),end=rdtsc();//rdtsc_delay ~85 cycles;


s1 n1,n2,n3,n4;
//hexchartodec   
start=rdtsc();
n1=hexchartodec('1');
n2=hexchartodec('f');
n3=hexchartodec('d');
n4=hexchartodec('5');
end=rdtsc();
printf("hexchartodec(Post >>1) Chars:%d,%d,%d,%d time:%llu cycles\n",n1,n2,n3,n4,(end-start));
//hexchartodec2
start=rdtsc();
n2=hexchartodec2('1');
n1=hexchartodec2('f');
n4=hexchartodec2('d');
n3=hexchartodec2('5');
end=rdtsc();
printf("hexchartodec2(Post >>7) Chars:%d,%d,%d,%d time:%llu cycles\n",n2,n1,n4,n3,(end-start));
//hexchartodec3
start=rdtsc();
n3=hexchartodec3('1');
n2=hexchartodec3('f');
n4=hexchartodec3('d');
n1=hexchartodec3('5');
end=rdtsc();
printf("hexchartodec3(Post >>20) Chars:%d,%d,%d,%d time:%llu cycles\n",n3,n2,n4,n1,(end-start));
//hexchartodec4start=rdtsc();
start=rdtsc();
n3=hexchartodec4('1');
n2=hexchartodec4('f');
n4=hexchartodec4('d');
n1=hexchartodec4('5');
end=rdtsc();
printf("hexchartodec4(Post >>25) Chars:%d,%d,%d,%d time:%llu cycles\n",n3,n2,n4,n1,(end-start));
//hex2dec
start=rdtsc();
n4=hex2dec('1');
n1=hex2dec('f');
n2=hex2dec('d');
n3=hex2dec('5');
end=rdtsc();
printf("hex2dec(Post >>34) Chars:%d,%d,%d,%d time:%llu cycles\n",n4,n1,n2,n3,(end-start));



}

Name: Anonymous 2012-01-07 5:20

>>24
Thanks bro!  Works fine.  (Couldn't get SALC working on a cheap Core 2 processor.)
unsigned char
hexToDec2(unsigned char x)
{
    unsigned char output;

    asm(
        "mov $0xf,%%al;"
        "and %[input],%%al;"

        "bt $4,%[input];"
        "sbb %%bl,%%bl;"
        "and %%al,%%bl;"
        "mov %%bl,%[output];"

        "add $9,%%al;"
        "bt $6,%[input];"
        "sbb %%bl,%%bl;"
        "and %%al,%%bl;"
        "add %%bl,%[output];"

        : [output] "=X"(output)
        : [input] "X"(x)
        : "al", "bl");

    return output;
}

Name: Anonymous 2012-01-07 5:25

>>36
Copypaste code, looks like shit..

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2012-01-07 5:30

fixed style to abstract away the code blocks.
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#define u1 unsigned char
#define u2 unsigned short
#define u4 unsigned int
#define u8 unsigned long long
#define s1 signed char
#define s2 signed short
#define s4 signed int
#define s8 signed long long
#define f2 short float
#define f4 float
#define f8 double
#define f10 long double
#define hexchartodec3(x) (((x>>6)+((x>>6)<<3))+(x&0xf))
#define timefunc(F)  ;start=rdtsc();n1=F('1');n2=F('f');n3=F('d');n4=F('5');end=rdtsc();printf("%s Chars:%d,%d,%d,%d time:%llu cycles\n",#F,n1,n2,n3,n4,(end-start));

int hex2dec(int c) {
    static const char *s = "0123456789ABCDEF";
    char *p;
    if (p = memchr(s, toupper(c), 16))
        return p - s;
    else {
        errno = EDOM;
        return -1;
    }
}




u8 inline rdtsc(){__asm{RDTSC}}
char hexchartodec_map[256] = {
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  1,  2,  3,  4,  5,  6,  7,  8,  9,  0,  0,  0,  0,  0,  0,
            0,  10, 11, 12, 13, 14, 15, 0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  10, 11, 12, 13, 14, 15, 0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
    };

char hexchartodec(char i) {
        return hexchartodec_map[i];
}
char hexchartodec2(const char c) {
    char d = c - '0';
    /* This if kind of means c >= '@', the compiler can't assume that c < 128
     * (i also can't do that, but i don't give a fuck) */
    if (c & 0x40) { //c to avoid a pipeline stall (we will have more below)
        /* The point here is that ('1'+16='A')+32='a'.*/
        --d; //or maybe d = c - '1';
        d &= 0xf; /* from the alignment of the ascii table, the least
                   * significant decimal is ready */
        d += 10;
    }
    return d;
}
char  hexchartodec4(char i){
switch(i){//since multiple IFS in chain are retarded
case '0':;return 0;
case '1':;return 1;
case '2':;return 2;
case '3':;return 3;
case '4':;return 4;
case '5':;return 5;
case '6':;return 6;
case '7':;return 7;
case '8':;return 8;
case '9':;return 9;
case 'a':;return 10;
case 'b':;return 11;
case 'c':;return 12;
case 'd':;return 13;
case 'e':;return 14;
case 'f':;return 15;
default:return 0;
}}
main(s4 argc,s1**argv){
u8 start,end;//rdtsc_delay ~85 cycles;
s1 n1,n2,n3,n4;
timefunc(hexchartodec);
timefunc(hexchartodec2);
timefunc(hexchartodec3);
timefunc(hexchartodec4);
timefunc(hex2dec);
}

Name: Cudder !MhMRSATORI!FBeUS42x4uM+kgp 2012-01-07 6:28

>>36
Your compiler and CPU is horrible.

I had to redefine >>20 as a function to stop my compiler from simply substituting in the values, since they're all constants. With even first-level optimizations all of them take ~18 cycles (the RDTSC latency on my CPU) since the compiler optimizes away the code entirely. I also added a loop to repeat each one 1048576 (1M) times. These are all without optimization:

rdtsc latency: 27 cycles
hexchartodec(Post >>1) Chars:1,15,13,5 time:18016572 cycles/1M = 17.18 cycles/iteration
hexchartodec2(Post >>7) Chars:1,15,13,5 time:27049857 cycles/1M = 25.80 cycles/iteration
hexchartodec3(Post >>20) Chars:1,15,13,5 time:30027546 cycles/1M = 28.64 cycles/iteration
hexchartodec4(Post >>25) Chars:1,15,13,5 time:33271920 cycles/1M = 31.73 cycles/iteration
hex2dec(Post >>34) Chars:1,15,13,5 time:369429444 cycles/1M = 352.32 cycles/iteration
hexchartodec5(mine) Chars:1,15,13,5 time:14012856 cycles/1M = 13.36 cycles/iteration


Here's mine:

and al, 4fh
mov dl, al
mov cl, al
shr dl, 6
shr cl, 3
add al, dl
add al, cl
and al, 15

Name: Cudder !MhMRSATORI!FBeUS42x4uM+kgp 2012-01-07 6:35

>>37
hexchartodec6(Post >>37) Chars:1,15,13,5 time:25221651 cycles/1M = 24.05 cycles/iteration

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2012-01-07 6:37

>>40
The whole point is to make a it macro, the function call overhead is really noticeable

Name: Cudder !MhMRSATORI!FBeUS42x4uM+kgp 2012-01-07 6:57


hexchartodec7(mine) Chars:1,15,13,15 time:13011942 cycles/1M = 12.41 cycles/iteration



mov ah, al
and ah, 4
and al, 15
shr ah, 2
aad 9  // CISC IS AWESOME


Anyone want to go for <10 cycles?

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2012-01-07 7:03

You can try writing a better macro than >>20 // CISC IS UNPORTABLE

Name: Cudder !MhMRSATORI!FBeUS42x4uM+kgp 2012-01-07 7:25

>>44
hexchartodec3m(Post >>20, modified) Chars:1,15,13,5 time:25927290 cycles/1M = 24.73 cycles/iteration

#define hexchartodec3m(x) ((((x&64)>>3)+((x&64)>>6)+x)&15)

Slightly better than >>7 but still nowhere near OP (fastest but largest portable one --- on x86, that is) nor the asm versions.

Strangely enough xlatb isn't faster than OP's on x86, even though it's a specific table lookup instruction (and was kept in 64-bit mode, for some reason.)

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2012-01-07 7:34

>>45
>((((x&64)>>3)+((x&64)>>6)+x)&15)
That looks like >>13 i thought it was abit slower.
Also, the loop just calls the table in cache at full CPU speed in single opcode

Name: Anonymous 2012-01-07 8:03

unsigned int
hexToDec(unsigned char x)
{
    return ( (x & 0xf)      * ((x & 0x10) >> 4))
         + (((x & 0xf) + 9) * ((x & 0x40) >> 6));
}

Name: Anonymous 2012-01-07 8:27

Silly Cudder, still puts a whitespace betwixt his name and the hash character.
That's not how you should trip on world4ch silly Cudder!

Name: Cudder !MhMRSATORI!FBeUS42x4uM+kgp 2012-01-07 8:34

>>48
The 0x20 is part of my name.

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2012-01-07 8:39

>>47
This is A.Retarded B.Haskell
>>45
try to time this:
#define hexchartodec3m2(x) ((((x>>6)<<3)+(x>>6)+x)&15)

Name: Anonymous 2012-01-07 9:30

>>49
That's not very portable of you, I mean a whitespace is a whitespace but 0x20 is only ASCII and supersets of it.

Name: Anonymous 2012-01-07 9:38

>>51
But it's not a "whitespace", it's a "0x20" byte.

Name: Anonymous 2012-01-07 9:42

>>50
This is A.Retarded B.Haskell
C.Fast.

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2012-01-07 9:47

>>53
>C.Fast
The macro is order of magnitude faster(no function calls, no multiplies, no implied casts to char).
The braindead switch/ifs from python is faster.
The table is obviously faster.

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2012-01-07 9:54

/*
C:\Program Files\dmc8.50\dmc\dm\bin\code>hex
hexchartodec Chars:1,15,13,5 time:403 cycles
hexchartodec2 Chars:1,15,13,5 time:1819 cycles
hexchartodec3 Chars:1,15,13,5 time:87 cycles
hexchartodec4 Chars:1,15,13,5 time:2446 cycles
hex2dec Chars:1,15,13,5 time:5976 cycles
hexchartodec3m Chars:1,15,13,5 time:119 cycles
hexToDec Chars:1,15,13,5 time:2047 cycles
hexchartodec3m2 Chars:1,15,13,5 time:95 cycles
*/
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#define u1 unsigned char
#define u2 unsigned short
#define u4 unsigned int
#define u8 unsigned long long
#define s1 signed char
#define s2 signed short
#define s4 signed int
#define s8 signed long long
#define f2 short float
#define f4 float
#define f8 double
#define f10 long double
#define hexchartodec3(x) (((x>>6)+((x>>6)<<3))+(x&0xf))
#define hexchartodec3m(x) ((((x&64)>>3)+((x&64)>>6)+x)&15)
unsigned int
hexToDec(unsigned char x)
{
    return ( (x & 0xf)      * ((x & 0x10) >> 4))
         + (((x & 0xf) + 9) * ((x & 0x40) >> 6));
}
#define hexchartodec3m2(x) ((((x>>6)<<3)+(x>>6)+x)&15)
#define timefunc(F)  ;start=rdtsc();n1=F('1');n2=F('f');n3=F('d');n4=F('5');end=rdtsc();printf("%s Chars:%d,%d,%d,%d time:%llu cycles\n",#F,n1,n2,n3,n4,(end-start));

int hex2dec(int c) {
    static const char *s = "0123456789ABCDEF";
    char *p;
    if (p = memchr(s, toupper(c), 16))
        return p - s;
    else {
        errno = EDOM;
        return -1;
    }
}




u8 inline rdtsc(){__asm{RDTSC}}
char hexchartodec_map[256] = {
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  1,  2,  3,  4,  5,  6,  7,  8,  9,  0,  0,  0,  0,  0,  0,
            0,  10, 11, 12, 13, 14, 15, 0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  10, 11, 12, 13, 14, 15, 0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
    };

char hexchartodec(char i) {
        return hexchartodec_map[i];
}
char hexchartodec2(const char c) {
    char d = c - '0';
    /* This if kind of means c >= '@', the compiler can't assume that c < 128
     * (i also can't do that, but i don't give a fuck) */
    if (c & 0x40) { //c to avoid a pipeline stall (we will have more below)
        /* The point here is that ('1'+16='A')+32='a'.*/
        --d; //or maybe d = c - '1';
        d &= 0xf; /* from the alignment of the ascii table, the least
                   * significant decimal is ready */
        d += 10;
    }
    return d;
}
char  hexchartodec4(char i){
switch(i){//since multiple IFS in chain are retarded
case '0':;return 0;
case '1':;return 1;
case '2':;return 2;
case '3':;return 3;
case '4':;return 4;
case '5':;return 5;
case '6':;return 6;
case '7':;return 7;
case '8':;return 8;
case '9':;return 9;
case 'a':;return 10;
case 'b':;return 11;
case 'c':;return 12;
case 'd':;return 13;
case 'e':;return 14;
case 'f':;return 15;
default:return 0;
}}
main(s4 argc,s1**argv){
u8 start,end;//rdtsc_delay ~85 cycles;
s1 n1,n2,n3,n4;
timefunc(hexchartodec);// >>1
timefunc(hexchartodec2);//>>7
timefunc(hexchartodec3);//>>20
timefunc(hexchartodec4);//>>25
timefunc(hex2dec);//>>34
timefunc(hexchartodec3m);//>>45
timefunc(hexToDec);//>>47
timefunc(hexchartodec3m2);//>>50
}

Name: 2012-01-07 10:07

Name: Anonymous 2012-01-07 10:14

>>54,55
Must be some bug in your compiler (compiled without optimization flags in GCC 4.6.2;  I changed the result and parameter type to char for extra speed (from ~180 cycles)):

hexchartodec Chars:1,15,13,5 time:162 cycles
hexchartodec2 Chars:1,15,13,5 time:297 cycles
hexchartodec3 Chars:1,15,13,5 time:81 cycles
hexchartodec4 Chars:1,15,13,5 time:360 cycles
hex2dec Chars:1,15,13,5 time:14139 cycles
hexchartodec3m Chars:1,15,13,5 time:81 cycles
hexToDec Chars:1,15,13,5 time:162 cycles
hexchartodec3m2 Chars:1,15,13,5 time:90 cycles

Name: Anonymous 2012-01-07 10:21

And if you make it a macro it gets as fast as any of the others.

hexToDec Chars:1,15,13,5 time:81 cycles

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2012-01-07 10:30

/*
C:\Program Files\dmc8.50\dmc\dm\bin\code>hex
hexchartodec Chars:1,15,13,5 time:485 cycles
hexchartodec2 Chars:1,15,13,5 time:3164 cycles
hexchartodec3 Chars:1,15,13,5 time:73 cycles
hexchartodec4 Chars:1,15,13,5 time:3422 cycles
hex2dec Chars:1,15,13,5 time:11459 cycles
hexchartodec3m Chars:1,15,13,5 time:85 cycles
hexToDec Chars:1,15,13,5 time:2558 cycles
hexchartodec3m2 Chars:1,15,13,5 time:91 cycles
hexToDecChar Chars:1,15,13,5 time:3277 cycles
macroHexToDecChar Chars:1,15,13,5 time:78 cycles
*/
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#define u1 unsigned char
#define u2 unsigned short
#define u4 unsigned int
#define u8 unsigned long long
#define s1 signed char
#define s2 signed short
#define s4 signed int
#define s8 signed long long
#define f2 short float
#define f4 float
#define f8 double
#define f10 long double
#define hexchartodec3(x) (((x>>6)+((x>>6)<<3))+(x&0xf))
#define hexchartodec3m(x) ((((x&64)>>3)+((x&64)>>6)+x)&15)
unsigned int
hexToDec(unsigned char x)
{
    return ( (x & 0xf)      * ((x & 0x10) >> 4))
         + (((x & 0xf) + 9) * ((x & 0x40) >> 6));
}

char hexToDecChar(char x)
{
    return ( (x & 0xf)      * ((x & 0x10) >> 4))
         + (((x & 0xf) + 9) * ((x & 0x40) >> 6));
}
#define macroHexToDecChar(x) ( (x & 0xf)      * ((x & 0x10) >> 4))   + (((x & 0xf) + 9) * ((x & 0x40) >> 6))
#define hexchartodec3m2(x) ((((x>>6)<<3)+(x>>6)+x)&15)
#define timefunc(F)  ;start=rdtsc();n1=F('1');n2=F('f');n3=F('d');n4=F('5');end=rdtsc();printf("%s Chars:%d,%d,%d,%d time:%llu cycles\n",#F,n1,n2,n3,n4,(end-start));

int hex2dec(int c) {
    static const char *s = "0123456789ABCDEF";
    char *p;
    if (p = memchr(s, toupper(c), 16))
        return p - s;
    else {
        errno = EDOM;
        return -1;
    }
}




u8 inline rdtsc(){__asm{RDTSC}}
char hexchartodec_map[256] = {
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  1,  2,  3,  4,  5,  6,  7,  8,  9,  0,  0,  0,  0,  0,  0,
            0,  10, 11, 12, 13, 14, 15, 0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  10, 11, 12, 13, 14, 15, 0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
    };

char hexchartodec(char i) {
        return hexchartodec_map[i];
}
char hexchartodec2(const char c) {
    char d = c - '0';
    /* This if kind of means c >= '@', the compiler can't assume that c < 128
     * (i also can't do that, but i don't give a fuck) */
    if (c & 0x40) { //c to avoid a pipeline stall (we will have more below)
        /* The point here is that ('1'+16='A')+32='a'.*/
        --d; //or maybe d = c - '1';
        d &= 0xf; /* from the alignment of the ascii table, the least
                   * significant decimal is ready */
        d += 10;
    }
    return d;
}
char  hexchartodec4(char i){
switch(i){//since multiple IFS in chain are retarded
case '0':;return 0;
case '1':;return 1;
case '2':;return 2;
case '3':;return 3;
case '4':;return 4;
case '5':;return 5;
case '6':;return 6;
case '7':;return 7;
case '8':;return 8;
case '9':;return 9;
case 'a':;return 10;
case 'b':;return 11;
case 'c':;return 12;
case 'd':;return 13;
case 'e':;return 14;
case 'f':;return 15;
default:return 0;
}}
main(s4 argc,s1**argv){
u8 start,end;//rdtsc_delay ~85 cycles;
s1 n1,n2,n3,n4;
timefunc(hexchartodec);// >>1
timefunc(hexchartodec2);//>>7
timefunc(hexchartodec3);//>>20
timefunc(hexchartodec4);//>>25
timefunc(hex2dec);//>>34
timefunc(hexchartodec3m);//>>45
timefunc(hexToDec);//>>47
timefunc(hexchartodec3m2);//>>50
timefunc(hexToDecChar);
timefunc(macroHexToDecChar);
}

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2012-01-07 11:06

rdtsc is bit unreliable for exact cycle count, but it reflects the execution process opcode cost more than any artificial loop/function abstraction.

Name: Anonymous 2012-01-07 15:19

>>59
Please take your shitty broken macro abuse back to /g/

Name: Anonymous 2012-01-07 15:39

>>61
Actually, I believe /prog/ is the perfect place for something like that.

Name: Anonymous 2012-01-07 15:58

>>25 here

i did some profiling and optimized this according to how often i have encountered the hex values in various files

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>;;.

def hex_char_to_decimal_value(h):
   if h == "0":
      return 0
   elif h == "F" or h == "f":
      return int(str(hex_char_to_decimal_value("1")) + str(hex_char_to_decimal_value("5")))
   elif h == "1":
      return 1
   elif h == "2":
      return 2
   elif h == "4":
      return 4
   elif h == "8":
      return 8
   elif h == "5":
      return 5
   elif h == "7":
      return 7
   elif h == "E" or h == "e":
      return int(str(hex_char_to_decimal_value("1")) + str(hex_char_to_decimal_value("4")))
   elif h == "3":
      return 3
   elif h == "6":
      return 6
   elif h == "9":
      return 9
   elif h == "D" or h == "d":
      return int(str(hex_char_to_decimal_value("1")) + str(hex_char_to_decimal_value("3")))
   elif h == "A" or h == "a":
      return int(str(hex_char_to_decimal_value("1")) + str(hex_char_to_decimal_value("0")))
   elif h == "B" or h == "b":
      return int(str(hex_char_to_decimal_value("1")) + str(hex_char_to_decimal_value("1")))
   elif h == "C" or h == "c":
      return int(str(hex_char_to_decimal_value("1")) + str(hex_char_to_decimal_value("2")))

Name: Anonymous 2012-01-07 16:03

>>63
Please do not post your freedom at all costs GPL code here.

use MIT/BSD or public domain, ``faggot''

Name: Anonymous 2012-01-07 16:05

>>64
if you would like to purchase a commercial license for the above code, this option will be available soon!

Name: Anonymous 2012-01-07 16:11

>>65'
>purchasing shitty python code
>purchasing shitty unoptimized code
>purchasing long elif shitty code


no one cares about your shitty code

Name: Anonymous 2012-01-07 16:12

>>66
You must be proud of your h4xx0r 4chun qu0t1ng sk1llz.

Name: Anonymous 2012-01-07 16:15

>>67
back to /g/ with you

Name: Anonymous 2012-01-07 17:36

Just use a hashmap if you want speed.  This is what I use in my game code:


HashMap<Character, Integer> hexMap = new HashMap<Character, Integer> (16); // Initialize this to 16 for speed

hexMap.put('0', 0);
hexMap.put('1', 1);
hexMap.put('2', 2);
hexMap.put('3', 3);
hexMap.put('4', 4);
hexMap.put('5', 5);
hexMap.put('6', 6);
hexMap.put('7', 7);
hexMap.put('8', 8);
hexMap.put('9', 9);
hexMap.put('A', 10 + 0);
hexMap.put('B', 10 + 1);
hexMap.put('C', 10 + 2);
hexMap.put('D', 10 + 3);
hexMap.put('E', 10 + 4);
hexMap.put('F', 10 + 5);

if (hexMap.contains(new Character(c))) {
   return hexMap.get(new Character(c));
} else {
   throw new InvalidHexException(new String(c) + " is not a valid hex character");
}

Name: Anonymous 2012-01-07 17:53

>>69
LOLWUT
int[] hexMap = new int[256];
hexMap['0'] = 0;
hexMap['1'] = 1;
hexMap['2'] = 2;
hexMap['3'] = 3;
hexMap['4'] = 4;
hexMap['5'] = 5;
hexMap['6'] = 6;
hexMap['7'] = 7;
hexMap['8'] = 8;
hexMap['9'] = 9;
hexMap['A'] = 10;
hexMap['B'] = 11;
hexMap['C'] = 12;
hexMap['D'] = 13;
hexMap['E'] = 14;
hexMap['F'] = 15;

int parse(char c) {
  return hexMap[c];
}

Name: Anonymous 2012-01-07 17:55

>>70 which is the same thing that OP wrote

Name: Anonymous 2012-01-07 18:08

ITT FrozenVoid doesn't know what inlining is

Name: Anonymous 2012-01-07 18:22

>>63

You know, it would be much better to just use python's built in utility
>>>int("ff", 16)
output: 255


Ruby has one too
"ff".to_i(16)

Name: Anonymous 2012-01-07 18:23

>>72 He uses dmc, and wants to be a compiler like that.

Name: Anonymous 2012-01-07 18:25

>>73
So does C:
strtol("ff", NULL, 16);

Name: Anonymous 2012-01-07 18:35

>>73
[d@home ~]$ time echo '1000000.times do "ff".to_i(16) end' | ruby
real    0m0.359s
user    0m0.353s
sys    0m0.003s
[d@home ~]$ time echo 'for i in range(1000000): int("ff",16)' | python
real    0m0.724s
user    0m0.710s
sys    0m0.013s

Name: Anonymous 2012-01-07 18:38

>>74
He's a self-taught `expert' programmer
He doesn't know the C standard
He abuses macros
He's dumb

Name: Anonymous 2012-01-07 18:39

>>73,76
[d@home ~]$ time echo 'main(){ int i; for(i=0;i<1000000;i++) strtol("ff", 0, 16); }' | gcc -xc -
real    0m0.271s
user    0m0.063s
sys    0m0.033s
[d@home ~]$ time echo 'main(){ int i; for(i=0;i<1000000;i++) strtol("ff", 0, 16); }' | gcc -xc -
real    0m0.047s
user    0m0.023s
sys    0m0.017s

even with compilation time it's still faster

Name: Anonymous 2012-01-07 18:45

>>78

Because it's fucking C. We know.

Name: Anonymous 2012-01-07 18:50

>>70
That has one major bug.  If you pass in '!' you get the value zero, when it should throw an exception.

Name: Anonymous 2012-01-07 18:52

>>80 why?

Name: Anonymous 2012-01-07 18:54

ITT shitty C programmer who haven't read their standard library


long int dec = strtol(hex_string,null,16);

Name: Anonymous 2012-01-07 19:04

>>82
ITT shitty C programmer who haven't read the whole thread
>>75
>>78

Name: Anonymous 2012-01-07 19:08

>>34 already proposed strtol

Name: Anonymous 2012-01-07 19:18

>>69
java
games
Fuck off, ``cubicle monkey".

Name: Anonymous 2012-01-07 19:24

>>85
Why would you tell Notch to fuck off?

Name: Anonymous 2012-01-07 19:52

>>76
>ruby
SLOW AS FUCK

Name: Anonymous 2012-01-07 21:49

>>84
pronounced ``stir-tall''

Name: Anonymous 2012-01-07 22:08

>>88

I pronounce it as stir-toll, as in toilet or toll road.

Name: Anonymous 2012-01-08 0:56

>>89
Rhymes with Adderall.

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2012-01-08 2:39

/*
C:\Program Files\dmc8.50\dmc\dm\bin\code>hex
hexchartodec Chars:1,15,13,5 time:474 cycles
hexchartodec2 Chars:1,15,13,5 time:1195 cycles
hexchartodec3 Chars:1,15,13,5 time:85 cycles
hexchartodec4 Chars:1,15,13,5 time:2024 cycles
hex2dec Chars:1,15,13,5 time:7266 cycles
hexchartodec3m Chars:1,15,13,5 time:190 cycles
hexToDec Chars:1,15,13,5 time:1904 cycles
hexchartodec3m2 Chars:1,15,13,5 time:97 cycles
hexToDecChar Chars:1,15,13,5 time:1622 cycles
macroHexToDecChar Chars:1,15,13,5 time:656 cycles
strtoldec Chars:1,15,13,5 time:7642 cycles
*/
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#define u1 unsigned char
#define u2 unsigned short
#define u4 unsigned int
#define u8 unsigned long long
#define s1 signed char
#define s2 signed short
#define s4 signed int
#define s8 signed long long
#define f2 short float
#define f4 float
#define f8 double
#define f10 long double
#define hexchartodec3(x) (((x>>6)+((x>>6)<<3))+(x&0xf))
#define hexchartodec3m(x) ((((x&64)>>3)+((x&64)>>6)+x)&15)
unsigned int
hexToDec(unsigned char x)
{
    return ( (x & 0xf)      * ((x & 0x10) >> 4))
         + (((x & 0xf) + 9) * ((x & 0x40) >> 6));
}

char hexToDecChar(char x)
{
    return ( (x & 0xf)      * ((x & 0x10) >> 4))
         + (((x & 0xf) + 9) * ((x & 0x40) >> 6));
}
#define macroHexToDecChar(x) ( (x & 0xf)      * ((x & 0x10) >> 4))   + (((x & 0xf) + 9) * ((x & 0x40) >> 6))
#define hexchartodec3m2(x) ((((x>>6)<<3)+(x>>6)+x)&15)
#define timefunc(F)  ;start=rdtsc();n1=F('1');n2=F('f');n3=F('d');n4=F('5');end=rdtsc();printf("%s Chars:%d,%d,%d,%d time:%llu cycles\n",#F,n1,n2,n3,n4,(end-start));

int hex2dec(int c) {
    static const char *s = "0123456789ABCDEF";
    char *p;
    if (p = memchr(s, toupper(c), 16))
        return p - s;
    else {
        errno = EDOM;
        return -1;
    }
}

long int strtoldec(char c){
return strtol(&c,NULL,16);
}




u8 inline rdtsc(){__asm{RDTSC}}
char hexchartodec_map[256] = {
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  1,  2,  3,  4,  5,  6,  7,  8,  9,  0,  0,  0,  0,  0,  0,
            0,  10, 11, 12, 13, 14, 15, 0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  10, 11, 12, 13, 14, 15, 0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
    };

char hexchartodec(char i) {
        return hexchartodec_map[i];
}
char hexchartodec2(const char c) {
    char d = c - '0';
    /* This if kind of means c >= '@', the compiler can't assume that c < 128
     * (i also can't do that, but i don't give a fuck) */
    if (c & 0x40) { //c to avoid a pipeline stall (we will have more below)
        /* The point here is that ('1'+16='A')+32='a'.*/
        --d; //or maybe d = c - '1';
        d &= 0xf; /* from the alignment of the ascii table, the least
                   * significant decimal is ready */
        d += 10;
    }
    return d;
}
char  hexchartodec4(char i){
switch(i){//since multiple IFS in chain are retarded
case '0':;return 0;
case '1':;return 1;
case '2':;return 2;
case '3':;return 3;
case '4':;return 4;
case '5':;return 5;
case '6':;return 6;
case '7':;return 7;
case '8':;return 8;
case '9':;return 9;
case 'a':;return 10;
case 'b':;return 11;
case 'c':;return 12;
case 'd':;return 13;
case 'e':;return 14;
case 'f':;return 15;
default:return 0;
}}
main(s4 argc,s1**argv){
u8 start,end;//rdtsc_delay ~85 cycles;
s1 n1,n2,n3,n4;
timefunc(hexchartodec);// >>1
timefunc(hexchartodec2);//>>7
timefunc(hexchartodec3);//>>20
timefunc(hexchartodec4);//>>25
timefunc(hex2dec);//>>34
timefunc(hexchartodec3m);//>>45
timefunc(hexToDec);//>>47
timefunc(hexchartodec3m2);//>>50
timefunc(hexToDecChar);
timefunc(macroHexToDecChar);
timefunc(strtoldec);//>>82
}

Name: Anonymous 2012-01-08 2:45

FrozenVoid is retarded. Why would anyone in sane mind care about strtol speed?

Name: Anonymous 2012-01-08 2:47

>>91

please take your macro abuse shitty code back to /g/. Yes we know macros obviously will out perform normal functions. You can enjoy your broken performance all you want in your fantasy land that never actually gets used in the real world other than your toy programs that only you jerk to .

Name: Anonymous 2012-01-08 2:54

>>92
expecting Frozenvoid to know the benefits of using standard library functions

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2012-01-08 3:04

>>92-94
The real proper way to design such software is to obviously write a 10Kloc Java class to handle all possible errors and formats in safe and consistent manner following all Enteprise Design Patterns.

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2012-01-08 3:05

Since i never install Java, i wouldn't time it or test it, you have to make such test yourself.

Name: Anonymous 2012-01-08 3:23

>>95
>>96'
>2012
>not piping all your programs through a java program that then handles errors on the processes it runs

Name: Anonymous 2012-01-08 3:28

C:\Program Files\dmc8.50\dmc\dm\bin\code>hex`
>cares about wasted clock cycles
>uses Windows

Name: Anonymous 2012-01-08 3:32

F R O Z E N V O I D ERROR HANDLING

public class o{
public static void main(String args[]){
try{Runtime.getRuntime().exec(args[0]);}catch(Exception e){System.out.println("False sense of me actually handling the error within a separate process");}
}
}

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2012-01-08 3:46

>>98
if you need that ultimate performance you should use MSDOS.
Its faster than Linux, Mac, and Windows, and the program can run on all cores by itself.

Name: Anonymous 2012-01-08 3:48

>>100
thank you for showing us just how retarded you are.

never change

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2012-01-08 3:51

>>101
>Jealous of superior DOS performance
>Use inferior Lunix system

Name: Anonymous 2012-01-08 3:52

>>102
claims the man that doesn't know how to read

back to /g/ with you

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2012-01-08 3:55

>>103
If you need to save cycles, why are you refusing to switch to DOS?
Its obviously faster than Lunix, since it lacks the scheduler/process/kernel bloat.

Name: Anonymous 2012-01-08 4:08

>>104
Its obviously faster than Lunix, since it lacks the scheduler/process/kernel bloat.

The amount of retardation from you is unbelievable. This is course is the result of not knowing how to read i guess and thinking your self-taught `expert'ness is good

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2012-01-08 4:12

>>105
Just another excuse to stay on an inferior system.

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2012-01-08 4:17

Think of all the cycles >>98 wasted while using Lunix. Millions of context switches, megabytes of wasted kernel memory.
Thats pretty horrible.

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2012-01-08 4:20

>>98 Its time to repent,format the disk and install MS-DOS.

Name: Anonymous 2012-01-08 4:25

>>107
says the man using windows while benchmarking programs to get the faster cycles while at the same time preaching about MS-DOS


Why are you even using an OS if you want the least number of cycles used?

fucking idiot, next time you go off acting retarded think your actions through

Name: Anonymous 2012-01-08 4:36

>>108

When I used to run dos, I remember the fan running when the computer was just at the command prompt, sitting in idle, as if it was polling on something. On linux, my computer only starts to overheat when I am actually asking it to do something intensive. I think dos is cool and all, and kind of cute, but being more primitive does not necessarily mean faster.

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2012-01-08 4:50

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2012-01-08 4:56

The input loop in DOS was designed at the time when computers were not as energy intensive as space heaters.
286 didn't even have a fan.

Name: Anonymous 2012-01-08 5:05

>>112

I see. But still...

>>111

teeheehe

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2012-01-08 5:09

Of course no one sane would use DOS now. I just recommend it to >>98 since if he wants his cycles.

Name: Anonymous 2012-01-08 5:10


char hexchartodec(char i) {
  int a = (((i-58)&(47-i))>>31)&(i-48);
  int b = (((i-71)&(64-i))>>31)&(i-55);
  int c = (((i-103)&(96-i))>>31)&(i-87);
  return a | b | c;
}

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2012-01-08 5:12

Technically running a bootable CD with the test program is even faster, but it requires writing an OS layer yourself(like some DOS games which boot from diskettes). So if you wants the last cycles, boot a CD with your program.

Name: Anonymous 2012-01-08 5:16

http://en.wikipedia.org/wiki/Boot_2_Gecko
BOOT TO FIREFOX
JAVASCRIPT-ONLY
FINAL DESTINATION
FrozenVoid why are you using windows XP when you have the choice?

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2012-01-08 5:18

I don't need the last percents of cycles, XP gives enough(..except usb drivers for my mice which steal 5%)

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2012-01-08 5:20

Whoever designed Logitech drivers is a retard. Polling USB shouldn't take 5% of my CPU.

Name: Anonymous 2012-01-08 5:23

>>117

I'd be down to use firefox as my os.

Name: Anonymous 2012-01-08 5:27

>>116

I'd like to try doing something like this sometime for one of my games. You'd have to include all the drivers for the specific machine on the disc correct?

Name: Anonymous 2012-01-08 5:30

We already have "Bootable games", we call them console games.

Name: Anonymous 2012-01-08 5:35

>>122

implying console games don't run on an OS that provides common API/ABI for things including, but not limited to, OpenGL/DirectX

I do have to admit, really old games such as the NES are truly bootable, given that the ROM is all that runs.

Name: Anonymous 2012-01-08 9:32

>>123
Go back to the imageboards

Name: Anonymous 2012-01-08 11:09

>>118,119
windows drivers are retarded
fixed that for you!

Name: Anonymous 2012-01-09 4:10

this should be faster,especially on ARM(since shifts and rotates are folded into ops)
#define hexcharshift(x) ((((x>>6)+((x>>6)<<3))+((x<<28)>>28)))

Name: Anonymous 2012-01-09 4:18

The first ADD can be replaced by OR since its 100|1=101 or 000|000=0
#define hexcharshift2(x) ((((x>>6)|((x>>6)<<3))+((x<<28)>>28)))
VROOOOOOOOM

Name: Anonymous 2012-01-09 5:13

>>127

saying vroom vroom for optimized code considered extremely cute.

Name: Cudder !MhMRSATORI!FBeUS42x4uM+kgp 2012-01-09 5:40

>>126
No one cares, ARM doesn't even have a RDTSC equivalent.

Name: Anonymous 2013-03-05 2:15

It can be done with one instruction in System/38 assembly and that instruction can handle up to 16 MB of hex digits.
/* input in hex-digit, output in integer-form */
dcl dd binary-form char(2) auto;
dcl dd text-form char(4) auto init('000X');
dcl dd integer-form bin(2) unsgnd def(binary-form) pos(1);
dcl dd hex-digit char(1) def(text-form) pos(4);
cvtch binary-form, text-form;

Name: Anonymous 2013-03-05 5:49

>>1
Fastest way
accessing memory

/0

remember: any arithmetic operation is order of magnitude faster than a memory access

Name: Anonymous 2013-03-05 10:11

>>40
And that, kids, is why you learn assembly; faster than a hard-coded map.

Name: Anonymous 2013-03-05 14:56

>>129
Woah.
Oh my gosh.
You're the smartest person in the world.
You're amazing.

You're so SPECIAL. Clearly different than everyone else on the planet. Better, mentally faster than all the rest. Not an average or mundane sheep, but a SPECIAL human. More evolved. A master race consisting of one member.

Can I suck your dick? Maybe ingesting your semen will raise my IQ by 20 points.

Name: Anonymous 2013-03-05 15:36

>>133
Fuck off with your ironic posts.

Name: Anonymous 2013-03-05 15:40

>>133
>Can I suck your dick? Maybe ingesting your semen will raise my IQ by 20 points.
50$

Name: Anonymous 2013-03-05 18:57

lol who fuqin cares about this nerd shit ^^ just write apps in ruby and be done with it lel

Don't change these.
Name: Email:
Entire Thread Thread List