Immediate data

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Martin Johansen

    #1

    Immediate data

    Hi group

    Which types are immediates by default?
    It would be logical if they were of the largest compatible type..

    Any way, take these three examples, followed by my guess:

    1, int
    FFFFFFFF, unsigned int
    'a', int
    1.2, double
    1e300, double

    Thank you!
  • those who know me have no need of my name

    #2
    Re: Immediate data

    in comp.lang.c i read:
    [color=blue]
    >Which types are immediates by default?[/color]

    what are these `immediates' of which you speak? i see constants below.
    [color=blue]
    >It would be logical if they were of the largest compatible type..[/color]

    they are the narrowest sensible type. (char, short and float are not in
    this set.)
    [color=blue]
    >1, int[/color]

    correct.
    [color=blue]
    >FFFFFFFF, unsigned int[/color]

    this isn't a valid hexadecimal constant, you forgot the 0x prefix. given
    that as an assumed correction...

    it depends on the width of the implementation' s int's -- it can be int,
    unsigned int, long or unsigned long. i.e., you may think that 32 bit int's
    are universal -- they are not; plenty of platforms exist where int is 16 or
    64 bits (or other, seemingly stranger values). the most common types today
    are unsigned int or unsigned long.
    [color=blue]
    >'a', int
    >1.2, double
    >1e300, double[/color]

    correct.

    --
    a signature

    Comment

    • Jack Klein

      #3
      Re: Immediate data

      On Tue, 18 May 2004 02:25:56 -0700, Martin Johansen <mfag@online.no >
      wrote in comp.lang.c:
      [color=blue]
      > Hi group
      >
      > Which types are immediates by default?
      > It would be logical if they were of the largest compatible type..
      >
      > Any way, take these three examples, followed by my guess:
      >
      > 1, int
      > FFFFFFFF, unsigned int
      > 'a', int
      > 1.2, double
      > 1e300, double
      >
      > Thank you![/color]

      From the examples in your post, I assume what you are calling
      "immediates " is what the C standard just calls "constants" .

      The answer depends on both the way the constant is written and whether
      or not any suffixes are used.

      Decimal integer constants have the first type in which the value is
      representable out of int, long int, long long int. Octal or
      hexadecimal constants go through int, unsigned int, long, unsigned
      long, long long, unsigned long long.

      FFFFFFFF is an identifier or macro, not a constant, although
      0xFFFFFFFF is a constant. It might be signed int, unsigned int,
      signed long, or unsigned long, depending on the implementation' s
      representation of these types.

      All single character constants have type int.

      All floating point constants have type double unless they are suffixed
      with one of 'f', 'F', which makes them floats, or 'l' or 'L' which
      makes them long doubles.

      Buying a decent C reference book might be in order.

      --
      Jack Klein
      Home: http://JK-Technology.Com
      FAQs for
      comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
      comp.lang.c++ http://www.parashift.com/c++-faq-lite/
      alt.comp.lang.l earn.c-c++

      Comment

      Working...