Re: D.E. Knuth's strlen

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Eric Sosman

    #1

    Re: D.E. Knuth's strlen

    robertwessel2@y ahoo.com wrote:
    On Oct 16, 11:35 am, jacob navia <ja...@nospam.c omwrote:
    >[...]
    >#define H 0x8080808080808 080ULL
    >#define L 0x0101010101010 101ULL
    >[...]
    Nice. And the adaptations to other size operands (32 bit longs for
    platforms not supporting anything bigger than that) or wide characters
    are obvious. Too bad I don't see a way of generating the constants in
    a platform independent way.
    #include <limits.h>
    #define L (ULLONG_MAX / UCHAR_MAX)
    #define H (L << (CHAR_BIT - 1))

    --
    Eric.Sosman@sun .com
Working...