Strange struct syntax; type name:number

This is a discussion on Strange struct syntax; type name:number within the C Programming forums, part of the General Programming Boards category; Bowsing the source for glibc-2.4 I found this strange stuff in ieee754.h: Code: union ieee754_float { float f; /* This ...

  1. #1
    Mad OnionKnight's Avatar
    Join Date
    Jan 2005
    Location
    Umeň, Sweden
    Posts
    555

    Strange struct syntax; type name:number

    Bowsing the source for glibc-2.4 I found this strange stuff in ieee754.h:
    Code:
    union ieee754_float
      {
        float f;
    
        /* This is the IEEE 754 single-precision format.  */
        struct
          {
    #if	__BYTE_ORDER == __BIG_ENDIAN
    	unsigned int negative:1;
    	unsigned int exponent:8;
    	unsigned int mantissa:23;
    #endif				/* Big endian.  */
    #if	__BYTE_ORDER == __LITTLE_ENDIAN
    	unsigned int mantissa:23;
    	unsigned int exponent:8;
    	unsigned int negative:1;
    #endif				/* Little endian.  */
          } ieee;
    
        /* This format makes it easier to see if a NaN is a signalling NaN.  */
        struct
          {
    #if	__BYTE_ORDER == __BIG_ENDIAN
    	unsigned int negative:1;
    	unsigned int exponent:8;
    	unsigned int quiet_nan:1;
    	unsigned int mantissa:22;
    #endif				/* Big endian.  */
    #if	__BYTE_ORDER == __LITTLE_ENDIAN
    	unsigned int mantissa:22;
    	unsigned int quiet_nan:1;
    	unsigned int exponent:8;
    	unsigned int negative:1;
    #endif				/* Little endian.  */
          } ieee_nan;
      };
    What is this :number thing? Can't find much information about it. Some kind of initializer?

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Bit fields. It's the number of bits that variable is to take up. Read up on bit fields for more info.


    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  2. Question on l-values.
    By Hulag in forum C++ Programming
    Replies: 6
    Last Post: 10-13-2005, 05:33 PM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM
  4. ras.h errors
    By Trent_Easton in forum Windows Programming
    Replies: 8
    Last Post: 07-15-2005, 11:52 PM
  5. towers of hanoi problem
    By aik_21 in forum C Programming
    Replies: 1
    Last Post: 10-02-2004, 02:34 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21