From -6265313421918155272
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,290ced9644daa112,start
X-Google-Attributes: gidf78e5,public
From: Brian White <bcwhite@verisim.com>
Subject: Types with Bit-Sizes
Date: 1998/03/13
Message-ID: <35084BDC.4108978E@verisim.com>#1/1
X-Deja-AN: 333507162
Content-Transfer-Encoding: 7bit
X-Original-Date: Thu, 12 Mar 1998 15:55:56 -0500
Content-Type: text/plain; charset=us-ascii
X-Complaints-To: usenet@news20.bellglobal.com
X-Trace: news21.bellglobal.com 889736881 13684 (None) 206.47.27.93
Organization: Verisim, Inc.  http://www.verisim.com/
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUANQh8F+EDnX0m9pzZAQHj+AGAnBM/EXLSYsk5GjClYAOj/J3Yfzw3DCoy 7zQh/O8Ch0KREK8zPkGyQ1tpfgGEvIM5 =Ce9A
Mime-Version: 1.0
Newsgroups: comp.std.c++


Is there anything in the the ANSI C++ spec that provides for datatypes of
known bit sizes?

If not, could such a thing be added?  Such a thing is really needed when
making data structures that can be moved across machines.

In the past, I've used the following conventions and found they work
very well.

typedef	UINT32	...;	// an unsigned integer of _exactly_ 32 bits
typedef	SINT32	...;	// a signed integer of _exactly_ 32 bits
typedef	uint32	...;	// an unsigned integer of _at_least_ 32 bits
typedef	sint32	...;	// a signed integer of _at_least_ 32 bits

The "uint32" would be defined as a the type optimial for that compiler
that was a minimum of 32 bits long.  A "uint8" would probably be an
"unsigned char" while "sint16" and "sint32" would just be "int" (on a
32-bit machine, of course).

Of course, there are UINT16, SINT8, uint64, etc., as well.  I've also
defined FLOAT32, FLOAT64, float32, and float64 types using the same
conventions.

                                          Brian
                                 ( bcwhite@verisim.com )

-------------------------------------------------------------------------------
Seize the moment!  Live now.  Make "now" always the most important time. -- JLP
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]



