Search:

Type: Posts; User: flp1969

Page 1 of 20 1 2 3 4

Search: Search took 0.01 seconds; generated 3 minute(s) ago.

  1. First: Read the INSTALL file... Check what...

    First: Read the INSTALL file...

    Check what header file declares the function in INCLUDE_DIR
    Check which library to use in LIB_DIR
  2. Replies
    6
    Views
    165

    Wow... I didn't notice the '0xAA' (between single...

    Wow... I didn't notice the '0xAA' (between single quotes)... :)
  3. Yep... I've heard about antique systems with 9...

    Yep... I've heard about antique systems with 9 bit bytes and 36 bits word size! (PDP-7?) :)
  4. Thank you! This is very useful! []s Fred

    Thank you! This is very useful!

    []s
    Fred
  5. You are right: __builtin_clzll() and it is not...

    You are right: __builtin_clzll() and it is not portable... and I forgot sizeof returns the number of bytes, so I need to multiply sizeof( size_t ) by 8 as well... :)

    There is a small confusion...
  6. A small correction on Post #5: ......

    A small correction on Post #5:


    ...
    new_capacity = 1ULL << ( 8 * sizeof ( size_t ) - __builtin_clz( needed ) - 1);
    ...
  7. An warning: Don't do this: nodes = realloc(...

    An warning: Don't do this:

    nodes = realloc( nodes, *capacity * sizeof( Node ) );
    reallod() can fail (returning NULL). In that case, you'll loose the address contained in nodes pointer and get a...
  8. Replies
    72
    Views
    826

    Why not keep this simple. You are not, obviously,...

    Why not keep this simple. You are not, obviously, interested in a cryptographically secure RNG, so LCG, Mersene Twister, Xorshift128 or any other PRNG is suitable. A thread safe LCG is easy enough to...
  9. Replies
    6
    Views
    165

    0xA0 isn't ASCII or a valid UTF-8 char. In...

    0xA0 isn't ASCII or a valid UTF-8 char. In ISO-8859-1 (Latin1) or WINDOWS-1252 is a "non breaking space"...
    The printed char depends on your encoding... Example... if you do:

    ...
  10. Replies
    72
    Views
    826

    What suprises me is that you are dealing with...

    What suprises me is that you are dealing with mathematical problems (floating point, random numbers), but refuse to learn the proper mathematics...
  11. Replies
    72
    Views
    826

    Good books about random number generators: Luc...

    Good books about random number generators:

    Luc Devroye - Non Uniform Random Variates

    and, of course, volume 2 of the art of computer programming by Donald E. Knuth

    Donald E. Knuth - The Art...
  12. Replies
    72
    Views
    826

    Compare this to the "noise" you get with the LCG...

    Compare this to the "noise" you get with the LCG (rand)... You'll notice yours has some "regular" spots (not as random as it should be)...

    As I said... this is better than before, but rand() is...
  13. Replies
    72
    Views
    826

    Why "miss"? Example code to use RDRAND if...

    Why "miss"? Example code to use RDRAND if available and to make sure will always return a random valid value:

    #include <stdio.h>
    #include <stdlib.h>
    #include <stdint.h>

    /* Test if RDRAND is...
  14. Replies
    72
    Views
    826

    One more reason to check if your processor...

    One more reason to check if your processor supports RDRAND (AMD FX, maybe not!)... I recomend you do the same I did before: Declare 2 pointers to functions and initialize them after calling an "init"...
  15. Replies
    72
    Views
    826

    Ahhh... BTW... if your processor uses Big Endian,...

    Ahhh... BTW... if your processor uses Big Endian, I think it must be wise to do something like this. PPM format expects RR GG BB in that order:


    ...
    int t;
    val = t = rand2rgb( func() );

    #if...
  16. Replies
    72
    Views
    826

    The rand() function is ISO 9989 standard, not...

    The rand() function is ISO 9989 standard, not subject to any licensing (maybe ISO/IEC)... And, as far as I know, xorshift128+ isn't subject to licensing as well...



    If you want to avoid...
  17. Replies
    72
    Views
    826

    PPM (binary) Graphics format: P6 width height...

    PPM (binary) Graphics format:

    P6
    width height
    max-value-per-component
    <binary data> (RR GG BB RR GG BB ...)

    The first 3 lines are strings

    Example:
  18. Replies
    72
    Views
    826

    Post #43: You need to verify if your processor...

    Post #43: You need to verify if your processor supports RDRAND. That's why I did use that "constructor" attribute extension to GCC to check through CPUID.
  19. Replies
    72
    Views
    826

    Why are you trying to create a PRNG from scratch?...

    Why are you trying to create a PRNG from scratch? Usually it is difficult to do it right.
    Here's a code I use in a project because I don't like LCG (due to the less random nature of lower bits):

    ...
  20. Replies
    72
    Views
    826

    Better, but worse then LCG (rand()) - you can see...

    Better, but worse then LCG (rand()) - you can see "continuous" small blocks at the same color in the final picture...


    $ gcc -O2 -o random random.c
    $ ./random > pic.ppm
    $ eog pic.ppm

    Here I...
  21. Replies
    72
    Views
    826

    This one? #include #include...

    This one?


    #include <stdio.h>
    #include <stdlib.h>
    #include <time.h>
    #include <limits.h>

    // Scale n to 24 bit value (0xBBGGRR).
    // OBS: Uses long double because 'long' is 64 bits long in...
  22. Replies
    72
    Views
    826

    A simple test for the code at post #7... Take a...

    A simple test for the code at post #7... Take a look at:


    #include <stdio.h>
    #include <stdlib.h>
    #include <time.h>

    // Scale 'n' to 24 bits (0xBBGGRR).
    #define rand2rgb(n) \
    ( ( int ) (...
  23. If you read carefully the definition of printf()...

    If you read carefully the definition of printf() functions. All returns the number of printer characters. A negative value is returned only in case of "output error" (like using fprintf() and trying...
  24. Replies
    12
    Views
    327

    On a historical note, goto is seen as "wrong"...

    On a historical note, goto is seen as "wrong" because in the 60's Dijkstra (a famous professor) published an article saying so. Since then, everyone adopted this opinion as cannon.
    Ok... abusing the...
  25. Replies
    1
    Views
    154

    From scanf() manpage: RETURN VALUE On...

    From scanf() manpage:

    RETURN VALUE
    On success, these functions return the number of input items successfully matched and assigned; this can be fewer than provided for, or even zero, in...
Results 1 to 25 of 499
Page 1 of 20 1 2 3 4