Re: Proposal: New types in C++0x

From: David Hilsee (davidhilseenews_at_yahoo.com)
Date: 09/22/04


Date: Tue, 21 Sep 2004 21:39:17 -0400


"Ioannis Vranos" <ivr@guesswh.at.grad.com> wrote in message
news:ciqc9o$1fi7$1@ulysses.noc.ntua.gr...
> Since there is the need of a new 64-bit integer type, the approach taken
> should be extensible.
>
> What about introducing int64 being exactly 64 bit, int32 being exactly
> 32 bits and int16 being exactly 16 bits, and making short and int
> equivalent to int16, and long being equivalent to int32?
>
>
>
>
> My proposal more thoroughly:
>
> int16 is introduced and is an exact 16-bit type (of course additional
> padding bits are allowed). int and short become equivalent of it.
>
> That is, signed int16, int16, signed, signed int, int, signed short,
> short to be all equivalent. The same for the unsigned equivalents. That
> is unsigned int16 to be the same as unsigned int and unsigned, etc.
>
> int32 is introduced and holds exactly 32-bit values. long becomes
> another name of it, as was the case with the above.
>
> signed int32, int32, signed long, long are all the same.
>
> unsigned long is another name of unsigned int32.
>
>
> int64 is introduced and holds 64-bit values. signed int64 is equivalent
> and unsigned int64 is the unsigned type.
>
>
> So we can say:
>
> int64 x;
>
> vector<int32> someVector;
>
> list<unsigned int64> someList;
>
>
> int32 *p = new int32[10];
>
> long *pp = p;

Wouldn't imposing exact requirements on existing types potentially cause
incompatibility problems? If, for example, there exists a platform that
makes int a 32-bit value (which would include many platforms, I reckon),
then replacing int's representation with a 16 bit representation would break
old programs. I think it's best to define more specific types like int16,
int32, and int64, leave the other types alone, and let programs use the new
types as they are needed. That way, explicit representations are only used
as they are required. I believe this is the approach taken by the new C
standard, but I could be wrong.

-- 
David Hilsee


Relevant Pages

  • Re: sizeof stuff and declarations
    ... >> representation' of that type. ... I get 4 bytes in int, ... don't care about it) is that normally in practice objects of integral ... very exotic platform). ...
    (comp.lang.c)
  • Re: sizeof stuff and declarations
    ... >> But if they take the same amount of bytes, ... you're right about my platform. ... > representation' of that type. ... I get 4 bytes in int, ...
    (comp.lang.c)
  • Re: Is __int64 dead?
    ... For my personal tastes, I see long long int, and think something along the lines of "now, what size is int on this platform? ... If I need a 64-bit data types regardless of the platform I'm compiling to, I use __int64. ...
    (microsoft.public.vc.mfc)
  • Re: What is a type?
    ... The types are different but the underlying representation ... that an enumeration type exists at ... The type int is perfectly supported by ... When I get a 128MB memory disk in RAM/USB the sequence is linear ...
    (comp.lang.c)
  • Re: What is a type?
    ... The types are different but the underlying representation ... This makes it sound like an enumeration type and type "int" are ... Conversions between integer ...
    (comp.lang.c)

Loading