alignment

Alignment along 4-byte boundaries

I recently got thinking about alignment... It's something that we don't ordinarily have to consider, but I've realized that some processors require objects to be aligned along 4-byte boundaries. What exactly does this mean, and which specific systems have alignment requirements? Suppose I have an arbitrary pointer: unsigned char* ptr...

Why won't my images align properly?

I'm trying to make a dynamically sizable title banner, using fairly simple image tricks. I place the banner image in a table cell, and set the background-image of the table row to a one-pixel-wide repeat of the banner's right-most pixel column. Thus, the banner image appears to stretch to fit the screen width without stretching the logo....

C# P/invoke structure alignment

I'm trying to call NtGetContextThread from C# on AMD64. The problem is that the CONTEXT structure for AMD64 needs to be aligned on a 16-byte boundary, and when I call NtGetContextThread I always get STATUS_DATATYPE_MISALIGNMENT. I'm aware that C# can align individual members of a struct using the Pack attribute, but it doesn't seem to be...

center align contents of a listbox in silverlight

I have a list box which is of a certain fixed width. The number of items in the listbox varies. Is there a way to center the contents of the list box? The "Content Presenter" of the ListBoxItem ,centers each item inside its Template instead of centering it with respect to the entire listbox width. Sorry about not replying earlier. The i...

CSS: Center block but left align contents

I want a whole block to be centered in its parent, but I want the contents of the block to be left aligned. Examples serve best On this page : http://yaml-online-parser.appspot.com/?yaml=%23+ASCII+Art%0d%0a---+%7c%0d%0a++%5c%2f%2f%7c%7c%5c%2f%7c%7c%0d%0a++%2f%2f+%7c%7c++%7c%7c%5F%5F%0d%0a&type=python the ascii art should be cen...

Algorithm for determining Alignment of elements in C/C++ structs

Okay, Allow me to re-ask the question, as none of the answers got at what I was really interested in (apologies if whole-scale editing of the question like this is a faux-paus). A few points: This is offline analysis with a different compiler than the one I'm testing, so SIZEOF() or similar won't work for what I'm doing. I know it's i...

error C2719: '_Val': formal parameter with __declspec(align('16')) won't be aligned?

I'm trying to create a vector for D3DXMATRIXA16 like so: vector<D3DXMATRIXA16> matrices; and am getting the error: d:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(717) : error C2719: '_Val': formal parameter with __declspec(align('16')) won't be aligned e:\projects\emuntitled\em\emscratch\emshadow.h(...

Working out address alignment

Hi there, How do you work out the alignment of an address by just looking at it? On a 32bit system, an address of 0x12345670 means it's 16 byte aligned (because of the 0 on the end) right? So what about: 0x12345671 0x12345672 0x12345673 etc? Cheers, Jon ...

2D Shape Scaling

Hi well I got a problem about scaling shapes.Well I m trying to scale two similar shapes.It is in 2d and each shape has n points .I found a statement like this from a paper I read "The size of a shape is the root mean square distance between the shape points and it's centroid." So from this point if I calculate the size of both shapes...

Problem positioning lines of text next to a larger text block

I'm trying to position two lines of text next to a single word like "Monday" with just html and css similar to what you see in the screenshot below. In the final product the two lines that currently say "hi" and "blah" will be replaced with a little bit of text and input fields. The screenshot version was accomplished with the followi...

Vertically centered text in a multiline TextBox, is it possible?

I'm looking for a WinForms .NET control that behaves exactly like the WinForms TextBox control in multi-line mode, but instead of the text being anchored to the top of the text box, I would like the text to be aligned in the middle - vertically. So, just like there is a TextBox.TextAlign property that takes Left|Right|Center, I'd want a...

center image in a div too small for it?

So I have a div in my body that's a percentage width, and inside that a div with inline style as follows: text-align: center; margin-left: -15px; margin-right: -15px; overflow:hidden As you can see, I have text-align center on, which would, if the image was small enough for the div, center the image. But the percentage width div is de...

is there a simple way (macro?) to tell structure alignment?

I understand the structure alignment is 'implementation specific', but just wondering if there is any simple way to calculate the structure alignment, for example: typedef struct { char c; int i; } test; if sizeof(test) - (sizeof(char) + sizeof(int)) == 0 means alignment is 1 byte; if sizeof(test) - (sizeof(char) + sizeof(int...

How to center cell contents of a LaTeX table whose columns have fixed widths?

Consider the following piece of LaTeX code: \begin{tabular}{p{1in}p{1in}} A & B\\ C & D\\ \end{tabular} How can I make the contents of each cell aligned in the center of the cell rather than the left? Note that I want to make sure that the widths of my columns are fixed, so I cannot use the "c" position attribute instead of "p{.1in}...

How to I configure emacs in java mode so that it doesn't automatically align method parameters

In emacs, when I type: public void foo(String one, String two) { It tabifies like this: public void foo(String one, String two) { I'd rather it didn't, and just aligned parameters like other line continuations. How can I configure it not to do this? ...

Why do my text fields and text areas not align when they have the same width?

...

Serialize a C# class to binary be used by C++. How to handle alignment?

I am currently serializing a C# class into a binary stream using BinaryWriter. I take each element of the class and write it out using BinaryWriter. This worked fine as the C++ application reading this binary file supported packed structs and hence the binary file could be loaded directly. Now I have got a request to handle alignment ...

What is the proper CSS way to implement right-aligned text on table columns?

To my surprise I just found out that applying text-alignment to a table column is fairly bad supported in current browsers. Neither Firefox 3.5.2, Safari 4.0.3 or IE8 shows the "amount" column below as right aligned. HTML: <table class="full_width"> <caption>Listing employees of department X</caption> <col></col> <col></col> <c...

Question about pointer allignement

I'm working on a memory pool implementation and I'm a little confused about pointers alignment... Suppose that I have a memory pool that hands out fixed size memory blocks, at the point of memory pool creation I malloc((size)*(num of blocks)). If whats being allocated are objects and the size comes from the sizeof operator alignment sh...

alignment requirements for atomic x86 instructions

Microsoft offers the InterlockedCompareExchange function for performing atomic compare-and-swap operations. There is also an _InterlockedCompareExchange intrinsic. On x86 these are implemented using the cmpxchg instruction. However, reading through the documentation on these three approaches, they don't seem to agree on the alignment r...