473,387 Members | 1,569 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,387 software developers and data experts.

Padding bits

Many times I have seen padding bits being mentioned here. What is the
purpose of the padding bits?
Nov 2 '07 #1
6 4262
john wrote:
Many times I have seen padding bits being mentioned here. What is the
purpose of the padding bits?
I believe it's for making sure members are aligned according to the
hardware requirements. Well, I don't know exactly, actually, but it
seems reasonable enough. So, there...

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Nov 2 '07 #2
john wrote:
Many times I have seen padding bits being mentioned here. What is the
purpose of the padding bits?
Bits or bytes?

--
Ian Collins.
Nov 2 '07 #3
Ian Collins wrote:
john wrote:
>Many times I have seen padding bits being mentioned here. What is the
purpose of the padding bits?

Bits or bytes?
Don't the latter consist of the former? :-)

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Nov 2 '07 #4
john wrote:
Many times I have seen padding bits being mentioned here. What is the
purpose of the padding bits?
You might need to give more context.

Most often the term "padding bits" refer to the bits in the object
representation of some scalar type, which do not participate in forming
the value of that type. These bits might be simply unused. Or they may
serve some internal household purpose, like acting as parity bits,
error-correction bits etc. For example, on some system an object of type
'double' might occupy, say, 64 bits, buy only 60 might actually be used
to represent the value. The remaining 4 bits would become padding bits
in this case. They might serve some special purpose. It is quite
possible that they might be set by the implementation/hardware in some
specific fashion and setting them manually (like trying to zero a
'double' object with 'memset') might easily lead to undefined behavior.

Another area when the term "padding" is often mentioned is the padding
between the members of the structure. Although these are usually
referred to as "padding bytes", not "padding bits".

Unused bits in the allocation unit reserved for bit fields probably fall
somewhere in between.

--
Best regards,
Andrey Tarasevich
Nov 2 '07 #5
Andrey Tarasevich wrote:
>
Another area when the term "padding" is often mentioned is the padding
between the members of the structure. Although these are usually
referred to as "padding bytes", not "padding bits".
And what is the purpose of these padding bits/bytes between members of a
struct?
Nov 2 '07 #6
john wrote:
Andrey Tarasevich wrote:
>>
Another area when the term "padding" is often mentioned is the padding
between the members of the structure. Although these are usually
referred to as "padding bytes", not "padding bits".

And what is the purpose of these padding bits/bytes between members of a
struct?
To make them align on a 4 or 8 byte boundary, so that a straight
memory fetch can be used for each variable in the struct.
Nov 2 '07 #7

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

Similar topics

13
by: Amarendra | last post by:
Folks, This structure padding issue is bothering me now, could not locate a satisfactory answer on clc, so here it goes... I have a structure, given below: typedef struct { int flag; char...
16
by: s.seitz | last post by:
hi gods and programmers! i've got a weird problem with strlen() in C. in a current project, i need to AES_decrypt() some string. By now, i'm using the libssl (openssl) API. To get this...
2
by: manochavishal | last post by:
Hi, In standard i have come across: 6.2.6 Representations of types 6.2.6.1 General 6.When a value is stored in an object of structure or union type, including in a member object, the...
5
by: Hallvard B Furuseth | last post by:
Does struct assignment copy padding bytes? Some compilers do, but I couldn't find anything in the standard which says they must. What I need is for any padding bytes to contan initialized values...
14
by: Francine.Neary | last post by:
Consider the following situation. I have a large static array s of structs, say of size 500. I also need a smaller array of chars, say of size 100, which has nothing to do with the struct. To...
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
4
by: Ioannis Vranos | last post by:
Under C95: 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
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...

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.