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

long doubles

Name: Anonymous 2011-08-13 11:42


int main(void)
{
    long double test = 1;
    test <<= 1E1L;
    return 0;
}

test@test:~/test$ gcc -ansi -pedantic -Wall -O0 -o test test.c
test.c: In function ‘main’:
test.c:35:7: error: invalid operands to binary << (have ‘long double’ and ‘long double’)


So there is no way I can bit-shift the damn long double's?

Name: Anonymous 2011-08-13 15:30

>>16
I see you are not stuck in the shitting-your-pants phase :), so how would you press more juice out of this (architecture-specific of course and the architecture is AMD64):


unsigned long int *eratosthenes_sieve(const unsigned long int n)
{
    unsigned long int *sieve = NULL;
    register unsigned long int i, j, k;
    register const unsigned long int init_int = 0525252525252525252523;
    register const unsigned long int even_int = 0525252525252525252525;
    register const size_t bit_size = sizeof(*sieve)*8;
    register const size_t arr_size = (((n/bit_size)+1));
   
        sieve = malloc(sizeof(*sieve)*(((n/bit_size)+1)));
    if (sieve == NULL)
            return NULL;

    *sieve = init_int;
    for (i = 1; i < arr_size; ++i)
        *(sieve+i) |= even_int;

    for (i = 3, j = 0; pow(i,2) <= n; i += 2) {
        j = ((i%bit_size)-1 == 0? j+1 : j);
        if ((j < arr_size) && (((*(sieve+j)) & (1LU << (i%bit_size))) == 0)) {
            for (k = 2*i; k <= n; k += i)
                *(sieve+(k/bit_size)) |= (1LU << (k%bit_size));
        }
    }

    return sieve;
}

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