473,396 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Padding bits and char, unsigned char, signed char

Under C95:

Is it guaranteed that char, unsigned char, signed char have no padding bits?
Mar 28 '08 #1
4 3279
Ioannis Vranos wrote:
>
Under C95: Is it guaranteed that char, unsigned char, signed
char have no padding bits?
unsigned char, yes. The others by implication. I haven't checked
the standard. Why don't you?

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.

--
Posted via a free Usenet account from http://www.teranews.com

Mar 28 '08 #2
On Fri, 28 Mar 2008 16:01:54 -0500, CBFalconer wrote:
Ioannis Vranos wrote:
>Under C95: Is it guaranteed that char, unsigned char, signed char have
no padding bits?
Just a note: padding bits are a concept introduced in the standard in
C99; C90/C95 left much more unspecified about the representation of
integer types.
unsigned char, yes.
Where is this guarantee made? In C99, 5.2.4.2.1 makes it as clear as it
can: "The value UCHAR_MAX shall equal 2^CHAR_BIT - 1." I don't have a
copy of an older standard. Does it make the same guarantee?
The others by implication.
How so? What's preventing a signed integer type and its corresponding
unsigned type from having a different number of padding bits?
Mar 28 '08 #3
Harald van =?UTF-8?b?RMSzaw==?= wrote:
>
On Fri, 28 Mar 2008 16:01:54 -0500, CBFalconer wrote:
Ioannis Vranos wrote:
Under C95: Is it guaranteed that char,
unsigned char, signed char have no padding bits?

Just a note: padding bits are a concept introduced in the standard in
C99; C90/C95 left much more unspecified about the representation of
integer types.
unsigned char, yes.

Where is this guarantee made?
In C99, 5.2.4.2.1 makes it as clear as it
can: "The value UCHAR_MAX shall equal 2^CHAR_BIT - 1." I don't have a
copy of an older standard. Does it make the same guarantee?
It doesn't.
There's really nothing about padding in the "basic types" in C90.
The others by implication.

How so? What's preventing a signed integer type and its corresponding
unsigned type from having a different number of padding bits?
I think he meant char and signed char, but even then I disagree.

As far as I know, signed char can have padding bits.

--
pete
Mar 28 '08 #4
Harald van Dijk <tr*****@gmail.comwrites:
On Fri, 28 Mar 2008 16:01:54 -0500, CBFalconer wrote:
>Ioannis Vranos wrote:
>>Under C95: Is it guaranteed that char, unsigned char, signed char have
no padding bits?

Just a note: padding bits are a concept introduced in the standard in
C99; C90/C95 left much more unspecified about the representation of
integer types.
>unsigned char, yes.

Where is this guarantee made? In C99, 5.2.4.2.1 makes it as clear as it
can: "The value UCHAR_MAX shall equal 2^CHAR_BIT - 1."
But that alone is not enough, is it? The clearest statement comes
later in 6.2.6. p1: "For unsigned integer types other than unsigned
char, the bits of the object representation shall be divided into two
groups: value bits and padding bits (there need not be any of the
latter).". So, unsigned char has only value bits.

--
Ben.
Mar 28 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Steve | last post by:
Hi, i know this is an old question (sorry) but its a different problem, i need to write a binary file as follows 00000011 00000000 00000000 00000101 00000000 11111111
5
by: Stephen Mayes | last post by:
I this helloworld portable? I am vaguely aware of something called "structure padding" and wonder if it could affect this program since the struct only contains chars. #include <stdio.h>...
9
by: edware | last post by:
I want to read header data from a image file, and I have a struct that represent this header. But it seems like my compiler pads the data, resulting that my fread() call won't put the right...
40
by: Allan M. Bruce | last post by:
I am applying for my first jobs after completing my PhD. I have been asked by a company to go and take a C programming test to see how my C skills are. Apparantly this test is mostly finding...
77
by: borophyll | last post by:
As I read it, C99 states that a byte is an: "addressable unit of data storage large enough to hold any member of the basic character set of the execution environment" (3.6) and that a byte...
6
by: John Messenger | last post by:
I notice that the C standard allows padding bits in both unsigned and signed integer types. Does anyone know of any real-world examples of compilers that use padding bits? -- John
9
by: Ioannis Vranos | last post by:
Under C++03: Is it guaranteed that char, unsigned char, signed char have no padding bits?
3
by: vippstar | last post by:
Hey comp.lang.c I'm somewhat confused with bit padding. I tried searching the FAQ, but there isn't a search feature, so I used google and the search query: site:c-faq.com padding. I did not...
2
by: Mihai Rusu | last post by:
Hello I am trying to figure out if the standard allows integral type representations with padding (ie value representation != object representation). A conforming implementation can have: - a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.