Search:

Type: Posts; User: flp1969

Page 1 of 20 1 2 3 4

Search: Search took 0.01 seconds.

  1. Ahhh... and this works very well: int...

    Ahhh... and this works very well:

    int lessThan( int a, int b )
    { return (a - b) >> ( sizeof(int) * CHAR_BIT - 1 ); }
    Right shift with signed integers are "dependent of implementation",...
  2. Well... no '

    Well... no '<' operator here (hehe)...

    // Intel/AMD:
    int lessThan(int a, int b)
    {
    int r = 0;

    __asm__ __volatile__ (
    "cmpl %2,%1\n\t"
    "sets %b0"
  3. Hummmm.... interesting. Thanks.

    Hummmm.... interesting. Thanks.
  4. Just a warning... When you do: line = NULL,...

    Just a warning... When you do:


    line = NULL, len = 0;
    while ( getline( &line, &len, fp ) != -1 )
    {
    ...
    }
    You are asking to getline allocate enough space to hold the first line, but if the...
  5. Replies
    16
    Views
    317

    There is a "portable" way. Using frexpf(): ...

    There is a "portable" way. Using frexpf():


    float m;
    int e;

    m = frexpf( value, &e );
    printf( "Value=%f -> m=%f, e=%d\n", value, m, e );
    frexpf() returns values between 0<=m<1, and e is the...
  6. Windows has CreateProcess() function on Win32 API.

    Windows has CreateProcess() function on Win32 API.
  7. Replies
    7
    Views
    318

    Share your code... I have no experience with...

    Share your code... I have no experience with PIC32, but already skim both datasheets. Glad to help if I can...
  8. Replies
    4
    Views
    620

    GLFW (https://www.glfw.org/)

    GLFW
  9. Replies
    7
    Views
    318

    Nope, it isn't unusual. And I don't see the...

    Nope, it isn't unusual. And I don't see the problem. The implementation is trivial:

    1- setup a 16 bit result to 0;
    2- Set SDI to 1 and pulse the CNV signal (0 to 1 and back to 0, Tcnv ns [1->0...
  10. Replies
    7
    Views
    318

    Without the actual interface between PIC and AD...

    Without the actual interface between PIC and AD isn't possible to tell you anywhing. Show the circuit and your attempt with code...

    Did you tried the CS-Mode?

    16335
  11. A small program to test this: #include...

    A small program to test this:

    #include <stdio.h>
    #include <math.h>

    float fact ( unsigned int x )
    {
    float n = 1.0;

    while ( x > 1 )
  12. Replies
    5
    Views
    373

    Or, using the wrapper functions and worrying...

    Or, using the wrapper functions and worrying about endianess:


    #include <unistd.h>
    #include <arpa/inet.h>

    int n = 1;

    // Write all bytes of n in BIG ENDIAN format.
    n = htonl( n );
  13. Replies
    15
    Views
    589

    Using RDRAND: // test.c - code for x86-64...

    Using RDRAND:

    // test.c - code for x86-64 (gcc).
    #include <stdio.h>
    #include <stdlib.h>
    #include <x86intrin.h>

    static int check_rdrand ( void );
    static double rand_ ( double, double );
  14. Replies
    15
    Views
    589

    You asked for a "platform neutral" method......

    You asked for a "platform neutral" method... rand() returns an uniform distributed random number in the range 0..RAND_MAX, usually through a LCG algorithm. In a 32 bit processor this is, again,...
  15. Replies
    15
    Views
    589

    #define swapd(a,b) ( double t_; t_ = (a); (a) =...

    #define swapd(a,b) ( double t_; t_ = (a); (a) = (b); (b) = t_; }

    double rand_range( double min, double max )
    {
    double r;

    if ( min > max )
    swapd( min, max );

    r = rand() /...
  16. Replies
    7
    Views
    272

    Ok. At this magnitude a long double has 1 ULP =...

    Ok. At this magnitude a long double has 1 ULP = 0.5. It means the imprecision is +/- 0.25. As for a double, 1 ULP = 1024 giving an imprecision of +/- 512. To illustrate, 5579207423999930400.0 cannot...
  17. Replies
    7
    Views
    272

    What do you mean "large values"? double supports...

    What do you mean "large values"? double supports values between +/-1.78769*10⁰⁸ (large enough for me).
    Using long double is always a overkill (large object representation in memory and no support...
  18. Replies
    4
    Views
    455

    And: 1- gethostbyname() is an old and obsolete...

    And:

    1- gethostbyname() is an old and obsolete function. Use getaddrinfo();
    2- sockaddr_in.sin_addr.s_addr is a simple 'unsigned int'. Don't need 'memcpy()' to write on it;
    3- Don't use...
  19. author='Your name here' for file in *.c; do ...

    author='Your name here'
    for file in *.c; do
    sed -i "s/<File Name>/$file/;s/<Author>/$author/;s/<Date>/$(date)/" $file
    done
  20. Replies
    7
    Views
    685

    ridderunnersjw, think of pointers as types that...

    ridderunnersjw, think of pointers as types that hold an address and addresses are unsigned integers (linke indices of an array). In C there are a difference in declaring an object and using it. If...
  21. Ahhh... of course, since we change the scale from...

    Ahhh... of course, since we change the scale from 2⁰ to 2⁻! Nice catch.
  22. Replies
    3
    Views
    503

    Looks like you are trying to mimic the asprintf()...

    Looks like you are trying to mimic the asprintf() GNU's function:


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

    int asprintf ( char **p, char *fmt, ... )
    {
    int size;
  23. Replies
    6
    Views
    504

    There are some predefined symbols for Windows:...

    There are some predefined symbols for Windows: _WIN32 (this exists on mingw and VC++), __WINNT__
  24. That's interesting, Malcom! I completely forgot...

    That's interesting, Malcom! I completely forgot about linear interpolation!


    #include <stdlib.h>
    #include <float.h>

    #define lerp(min_, max_, norm) \
    ( (min_)*(1.0 - (norm)) + (max_)*(norm)...
  25. In time: You are correct about the duplicates....

    In time: You are correct about the duplicates. There are none. My mistake.
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4