Search:

Type: Posts; User: flp1969

Page 1 of 20 1 2 3 4

Search: Search took 0.01 seconds.

  1. And... sorry... I made a little mistake... To...

    And... sorry... I made a little mistake... To emulate && with the binary logical operator & you need to transform the values in both variables to boolean (0 or 1), like this:

    x += ( !!x & !!b );...
  2. Always a good idea to give a hand to the...

    Always a good idea to give a hand to the compiler, but be aware that it's not granted that a C jumpless code is compiled to a binary jumpless one...

    Usually, when using optimizations, the compiler...
  3. Just another tip... notice that there are BOOLEAN...

    Just another tip... notice that there are BOOLEAN operators and BINARY operators for logical operations... The expression above could be writen as:

    x += ( x && boolvar );
  4. Replies
    1
    Views
    136

    Take a look at OpenCL.

    Take a look at OpenCL.
  5. Vague? ISO defines the result of boolean...

    Vague? ISO defines the result of boolean expressions to be 0 (false) or 1 (true). But for testing boolean values, 0 is false and non-zero, true.

    I would use

    #define FALSE 0
    #define TRUE 1
    ...
  6. Replies
    3
    Views
    182

    When data on a stream cannot be converted it...

    When data on a stream cannot be converted it stays in the stream buffer. When you type 'bob' scanf() will return 0 and "bob\n" will stay in the stdin's buffer... the latter scanf() will read 1 char...
  7. Thread: Tricky typedef

    by flp1969
    Replies
    5
    Views
    280

    Trying to explain the declaration... This: ...

    Trying to explain the declaration... This:

    unsigned int func( void *p );
    Is a function named func which returns an unsigned int and takes a pointer to void as argument, right?

    This:
    ...
  8. Not an anomaly... Someone shown me this and I got...

    Not an anomaly... Someone shown me this and I got directly to ISO standard (C99) and it is there... It's a valid expression.
    Does nothing really (except create that annonymous automatic object) --...
  9. An interesting and strange (in my opinion) expression.

    I was amazed to learn that this works:


    (int){ 0 } = 1;
  10. Replies
    10
    Views
    395

    Incomplete array declarations can be "incomplete"...

    Incomplete array declarations can be "incomplete" only in the "first" dimension. The reason is this: Suppose you have an array like yours:

    int arr[421][69];
    To access the element arr[i][j] the...
  11. Replies
    3
    Views
    248

    I strongly recommend to avoid using system() in...

    I strongly recommend to avoid using system() in any project. And I think Salem is right saying this is better suited to a script/batch file. Just as an exercise here's my implementation using...
  12. This happens because VLAs don't have a known...

    This happens because VLAs don't have a known constant length (ISO 9899 6.2.5 23). The compiler don't know the size of the array (even if you use a pre initialized size through a 'const' variable)...
  13. Replies
    1
    Views
    306

    English and a picture: After initializing a,...

    English and a picture:

    After initializing a, arr and p you have:

    16296

    *arr[1] will give you 2, since p points after the last element of a, p[2-5] will give you p[-3]. This gives you 2 also.
  14. Replies
    7
    Views
    228

    snprintf() [and vsnprintf()] don't return the...

    snprintf() [and vsnprintf()] don't return the number of chars printed (as printf() do), but the number that would be printed. For example:


    int size;
    char buffer[10];

    size = snprintf( buffer,...
  15. And, in other architetures besides Intel (like...

    And, in other architetures besides Intel (like ARM) these functions are different. Here the 3 isCrossing() in ARM Cortex-A53 using vfp3-d16:


    isCrossing:
    ldm r0, {r0, r3}
    lsr r3, r3, #31
    ...
  16. The second tip is ok (droping a !), but the third...

    The second tip is ok (droping a !), but the third is a little bit different, since uses two floating point comparisons.
    Notice signbit simply isolates the sign bit without any comparison... The...
  17. NOT a correction, just a little bit of...

    NOT a correction, just a little bit of improvement. Instead of:


    bool isCrossing(float *pair) {

    return pair[0] < 0 && pair[1] >= 0 ||
    pair[0] > 0 && pair[1] <= 0;
    }

    Well......
  18. Replies
    10
    Views
    579

    leopoldo100, when you say "very simple" it means...

    leopoldo100, when you say "very simple" it means from a user point of view. Video players aren't "simple", even when using some library (like ffmpeg's libav*).
  19. Yep... Try to compile the same code for i386 (or...

    Yep... Try to compile the same code for i386 (or x86, as you called) and you'll get:

    section .text

    _multiplyByTwo:
    fld QWORD [esp+4]
    fadd st, st(0)
    ret

    section .rdata
  20. Unless you are compiling your code without any...

    Unless you are compiling your code without any optimizations enabled, the compiler will use the stack to store local variables only if needed. In general, for optimized code, the compiler uses...
  21. Replies
    6
    Views
    530

    Notice you can use getline() [POSIX] to get a...

    Notice you can use getline() [POSIX] to get a line of any size (dynamically allocated), strtok() to isolate "pieces" of the line and strtoul() to try to convert strings from octal to unsigned long...
  22. Replies
    6
    Views
    530

    Another small thing... In the comments you said:...

    Another small thing... In the comments you said:

    "Write a function that reads data from standard input until EOF is found and returns the sum of the base-8 numbers found into the input."

    So,...
  23. XOR has 3 basic uses: To invert bits based in a...

    XOR has 3 basic uses: To invert bits based in a mask; To get the result of different bits in both operands or as a caryless add.
    This kind of code is a trick to swap values without using a temporary...
  24. Replies
    9
    Views
    1,184

    UNICODE encoding is a 31 bits value corresponding...

    UNICODE encoding is a 31 bits value corresponding to a single character. The trailing 16 bits correspond to a character in a "plane" the upper 16 bits. Actually planes 0, 1, 2, 3, 14, 15 and 16 are...
  25. Replies
    17
    Views
    1,087

    Easier if you check only if the next value is...

    Easier if you check only if the next value is greater than the previous (or vice-versa).
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4