Ok, let's dig into this. [QUOTE=prvnkmr449;1328943]As I understand your problem is to minimize this highly nested loop which print the value of 12 variable. [/quote] You should note that the program calls two functions [icode]a()[/icode] and [icode]b()[/icode]. So, it is doing more than just printing out the values of variables. At any rate, yes, this seems to be the main push of the program. [QUOTE=prvnkmr449;1328943] Here is my very short program for that but very deep logic is behind that please try to understand the logic behind this first take look too code [/quote] 1. Program isn't that short 2. Logic isn't that deep 3. Maybe you should present your algorithm in clearer terms instead of slapping the reader with convoluted pure C code and expecting them to follow [CODE] long double n_digit= 5;//0,1,2 long double n_var =4;//x,y,z long double dif_com =pow( n_digit,n_var); [/code] When I got here, I knew we were in for a doozy. I notice that you are calculating the number all possible combination of n-digit numbers in a b-based numbering system. First of all, this is not necessary. Secondly, it is wrong. Let's investigate why First look at a section of the OP's code: [code] for(int i=5;i>0;i--) { for(int j=5;j>0;j--) { if(j
Akill10 commented: well said! +1

I forgot to mention that you use the above code for your application by subsituting an array (or vector, etc) of ints for the loop control variables. So:

[icode]

i j k ... t
| | | |
v v v v
[ 4 4 4 ... 2 ]
[/icode]

What it appears to me is that you have a specialized base-5 numbering system. It is specialized in that it has rules that dictate how you count down in this system. You could make this system very extensible and have it work with an arbitrary number of digits and arbitrary numerical base. The best way to do this is to develop some rules:

• A number in this system may have an arbitrary numerical base b
• A number in this system may have an arbitrary number of digits n
• No digit at index i in the number may be larger than the digit at index i-1

I have implemented a system like this before. I had to create my own specialized numbering system for this problem: [url]http://www.daniweb.com/forums/thread280248.html[/url]

Try implementing something like this:

[icode]
b = 5 # 5 is arbitrarily chosen. this could be any number
n = 24 # again, 24 is arbitrary
num = array[n]
for i from 0 to n:
num[i] = b - 1 # Set all numerals to b-1

while num[0] > 0: # Terminate when the leftmost digit is 0.
[COLOR="Green"]do something with num[/COLOR] # All the rest of the code is counting down
j = n - 1
num[j] -= 1 # Decrement the right-most digit
while num[j] < 0: # If the digit goes below 0, you have to decrement the digit to the left
j -= 1
num[j] -= 1
while j < n - ...

@OP

I see no reason for the Die object to store the result of its roll. There is nothing wrong with this idea. However, it seems that you will always first roll the die and then fetch its value. This could be accomplished in one step by having the roll() function return the result of the roll. You could still store the result, if you really wanted to, and fetch it again later with the getFace() function:

[code]
int Die::Roll()
{
face = rand() % 6 + 1;
return face;
}

int Die::getFace()
{
return face;
}
[/code]

if you don't need to store the result (i.e. you will use it right away):
[code]
int Die::Roll()
{
return rand() % 6 + 1;
}
[/code]

The [icode]DiceRoll::rollDice()[/icode] and [icode]DiceRoll::getRollFaces()[/icode] could be consolidated in the same way.

Fbody commented: Both good points, but please see response. +2

This is unnecessary code:
[CODE]
bool Candidate::operator ==(const Candidate& right) const
{
//return (firstName == right.firstName && lastName == right.lastName);
// Rather than the above, I used this...
return (static_cast(*this) == static_cast(right));
}
[/CODE]

If you do not define this operator in your derived Candidate class, the operator function from your base Person class will be used. I think you need to work on the concepts of inheritance a little bit.

Consider this:

[code]

include

using namespace std;

class Base
{
int value;
public:
Base( int value ) : value(value){}
bool operator==( const Base& other )
{
return value == other.value;
}
};

class Derived : public Base
{
public:
Derived( int value ) : Base(value){}
};

int main()
{
Base b0( 4 );
Derived d0( 2 * 2 );
Derived d1( 2 + 2 );
cout << ( b0 == d0 ) << endl;
cout << ( b0 == d1 ) << endl;
cout << ( d0 == d1 ) << endl;
return 0;
}
[/code]

If you can understand why this works, you are on your way.

[QUOTE=nizbit;1320079]I'm trying to find duplicates in an array and removing them by shifting the array index using the same array. I can't figure out where in my code the problem is but I'm still getting a duplicate. Could someone please help pinpoint the problem? I've tried debugging it but I'm not seeing it.
[CODE]

include

using namespace std;

int removeDuplicates(int A[], int n){
int last = n-1;
int found = 0;
//bool flag = false;

``````for(int i=0; i < last+1; i++)
{
for(int j=i+1; j < last+1; j++)
{
if(A[i] == A[j])
{
found++;
for(int k = j;k < last+1;k++)
{
A[k]=A[k+1];
//if(A[k-1] == A[i])
//  flag = true;
}
last--;
j=j+1;
}

}``````

}
//found= last-found;
return last;
}

int main() {

``````// Test data
int n = 24;
int A[] = {1,1,2,4, 1,1,1,2, 3,5,8,0, 2,-2,-4,1, 9,10,-4,11, 11,8,5,-4};

// Call
int last = removeDuplicates(A,n);

// Print Results
for(int i = 0; i <= last; i++)
cout << A[i] << " ";
cout << endl;

return 0;``````

}
[/CODE][/QUOTE]

I see one fundamental problem here. You are shifting your j index [I]even when a duplicate is found[/I]. When you find a duplicate and shift all items, you need to leave the j index in place:

[icode]

1. Found duplicate

i j
| |
v v
ABCDEFGHIJEEKLMNO

2. Shift

i j v v
ABCDEFGHIJEEKLMNO
vvvvvv
``````   //////
||||||
vvvvvv ``````

ABCDEFGHIJEKLMNO

3. Incorrect increment of j

i j
| |
v v
ABCDEFGHIJEKLMNO
^
|_____There is still a duplicate, ...

mrnutty commented: Nice Ascii Art and good explanation. +5

My friend, you are suffering through pointer hell. The best way to avoid this is to use the standard template library. Vectors are infinitely nicer than dynamically allocated arrays of pointers. In order to understand your code, I had to work through it. In the process, i utilized the standard template library. The code worked almost immediately after eliminating compiler errors. Here it is:

[code]

include
include

class neuron
{
public:
// Other members and constructors omitted

``````std::vector<neuron*> connections;

void connect( const std::vector<neuron*>& inconnections )
{
connections.clear();
for( unsigned int i=0; i<inconnections.size(); i++ )
{
if( this == inconnections[i] )
continue;
connections.push_back( inconnections[i] );
}
}

//Printing functions ommitted``````

};

class network
{
public:
std::vector<neuron*> neurons;

``````neuron*& slot( int i, int j )
{
return neurons[ i * w + j ];
}

network( int w, int h ): w(w), h(h)
{
neurons = std::vector<neuron*>( w * h, NULL );
for( int i=0; i<h; i++ )
{
for( int j=0; j<w; j++ )
{
slot( i, j ) = new neuron( i, j );
}
}
for( unsigned int i=0; i<neurons.size(); i++ )
neurons[i]->connect( neurons );
}

// Destructor and printing functions ommitted``````

};

using namespace std;

int main()
{
network net(2,2);
net.printNetwork();
return 0;
}

[/code]
Outut:
[icode]
Network structure:

My name is: [0,0]
I am connected to:
0,1
1,0
1,1
My name is: [0,1]
I am connected to:
0,0
1,0
1,1
My name is: [1,0]
I am connected to:
0,0
0,1
1,1
My name is: ...

[QUOTE=StuXYZ;1276358]Often, the act of asking the question, leads to you discovering the solution yourself. Please don't just make the thread solved, with a "found the problem", please take the trouble to tell us what you did wrong. Even if it is brain dead stupid, we may laugh, but we all have been there and done it [and in my case, I seem to continue to have BDS moments]. You certainly will earn a lot more respect for admitting the error than the "found the problem" post.[/QUOTE]

Great point. Sharing your solution may help others (that may be googling) who are experiencing the same problem. I know that when I read Linux threads looking for help on config issues, there is nothing more frustrating than finding a thread with my exact same problem that the OP marked solved with no explanation.

jonsca commented: Rep for the main post +4

I notice that there are many, many threads where posters receive few if any comments. When I open these threads, it is usually obvious right away why no one has bothered to reply. The problems with these posts vary from deliberate solicitation for homework solutions to poorly composed questions. I have assembled here 5 simple methods to make your post more interesting and clear to people who [I]want[/I] to help you

[icode]
[B]Problem inserting nodes into linked list[/B]
[B]Compiler error in template class constructor[/B]
[B]Trouble sorting Automobile Class[/B]
[B]How can I return two values from a function?[/B]
[/icode]
It is most important that your title describes what kind of help you are looking for. I imagine that, like me, most readers skim the forum for interesting posts and ignore any that seem too inane. Finally, make sure that [I]at least[/I] your title uses proper English. A thread title that ...

StuXYZ commented: Excellent! +3
Lusiphur commented: This should be stickied in every coding forum... +1
Ancient Dragon commented: Great post :) +31
Aranarth commented: Excellent! Now all that's left is that people read this post before starting a topic... +1

As a fanboy of Qt, I recommend you research it a little. It's a very powerful cross platform GUI based on c++. Any programs you write using the Qt API can be built on windows, mac, and linux ( among others ). While drawing shapes in a QGraphicsView is not especially simple ( the QGraphicsView widget has a ton of capabilities ), the Qt API is fairly easy to use. Like I said previously, it is very powerful, but it is also very well documented. There are many tutorials online, and the online documentation is extensive. To top it all off, Trolltech (the maker of Qt) has a [I]free[/I] integrated IDE called QtCreator for creating Qt projects. QtCreator is a full featured c++ IDE with a graphical designer for Qt widgets. Anyhow, I highly recommend Qt for anyone seeking to make interactive graphical programs in c++.

[URL="http://qt.nokia.com/products/"]Qt Homepage[/URL]
[URL="http://doc.qt.nokia.com/4.6/index.html"]Qt Documentation[/URL]

The first problem is in your class definition. The scope operator`( :: )`is only used when your class is declared in one place (like a .h header file) and the functions are defined in another place (like a .cpp source file). When you are declaring and defining a function in one place, using the `::` operator is incorrect. The class should be declared/defined in one place like so:

``````class SomeClass
{
SomeClass()
{
// Some initialization here
}

SomeClass( int someVal )
{
// Some initalization here
}
};``````

If you want to split the class declaration and definition, proceed like so:

``````// Declaration of class.  Probably appears in a .h file
class SomeClass
{
SomeClass();
SomeClass( int someVal );
};

// Definition of class functions.  Probably appears in a .cpp file
SomeClass::SomeClass()
{
// some initialization here
}

SomeClass::SomeClass( int someVal )
{
// some initialization here
}``````
1. When a pointer is declared

where is it pointing to? Does it create a memory address not attached to a variable where Player() is initialized?

Think I'm not understanding new as you can't declare

as new Player() is a pointer type.

The key here is understanding the new operator. Whenever you use the new operator, you are asking for dynamic allocation. Basically, the program reserves some space in the heap for the new object instance, initializes it using the provided constructor, and returns a pointer to the ...

The problem is (most likely) that you have to define a template function in the same file where it is declared. For a good over-view and specifics on the multi-file problem, see [URL="http://www.cplusplus.com/doc/tutorial/templates/"]this[/URL].

So, you need to move your implementation of the split2 function to your header file. I know this will be ugly, but it's the only way to make it work well. You'll notice that many projects that use temlate classes and functions make use of a [B].hpp[/B] extension for header files with template implementations. This gives an indication that the header will contain both function declarations and definitions.

You need to first realize that there is no [][] operator. In fact whenever you see matrix2D[][] or matrix3D[][][] or matrixND[][]...[], you are actually seeing multiple nested calls on the [] operator.

Consider the case for a 2D matrix. If you declare the matrix like so:

``````int rows = 5;
int cols = 7;
int** myMatrix = new int*[rows];
for( int i=0; i<rows; i++ )
myMatrix[i] = new int[cols];``````

You are actually first declaring an array of int pointers. Each one of these int pointers is then pointing at another array of ints. The way this lies in memory can be looked at like this

``````array[ *, *, * ]
|  |  |
|  |  |---> array[ i, i, i ]
|  |
|  |------> array[ i, i, i ]
|
|---------> array[ i, i, i ]``````

So, when you are accessing an element of a Matrix like this:

``myMatrix[1][2];``

You are actually first accessing the element of the pointer array at position [COLOR="Red"]1[/COLOR], and then accessing the element of the nested int array at position 2:

``````          1
|
array[ *, *, * ]
|  |  |
|  |  |---> array[ i, i, i ]
|  |
|  |------> array[ i, i, i ]
|                        |
|                        2
|
|---------> array[ i, i, i ]``````

So, you can't really design a custom class that can in and of itself process the nested [] operators ( [][] ). You can, however, overload the [] or () operator to behave like this: ...

You need to declare the static member outside of the class definition like so

[code]

ifndef DIE_H
define DIE_H
include "aRandomNumberGenerator.h"

{
public:
double roll();
void seed (int s);
int inputSeed();

``````private:
static aRandomNumberGenerator gen;``````

};

endif
include
include

using namespace std;

// or
// or
// aRandomNumberGenerator aDie::gen = new aRandomNumberGenerator( ... );

{

}

{
return (fmod(gen.generate(), 6) + 1);
}

{
gen.setSeed(s);
}

{
int value;

``````cout << "Please enter a seed value: ";
cin >> value;

seed(value);

return value;``````

}

{
//Destructor does nothing in this case.
}
[/code]

The basic problem with detecting bodies is the inconsistency of orientation. You'll notice that the Face detector is really only good at detecting faces that are pointed more or less toward the camera, and the detector does not find rotated faces well. This is because it is looking for similar structure at multiple scales in a single orientation. Detecting bodies is going to be much more difficult if you can't count on the bodies being oriented in the same direction and can't count on the bodies having the same pose.

In order to detect bodies, you would need some sort of detector that operated by detecting [I]features[/I] of bodies and looking for clusters or connected components of these. This is not a trivial problem whatsoever. Using the detectors that ship with OpenCV will not help you much with this regardless of how many training images you supply.

Furthermore, we typically dress our bodies in clothing of different colors. If you were only detecting naked bodies, it would be much simpler. However, any sort of detector that you built would have to first be able to segment the structure of the body. This would most likely require some sort of edge finding, because you couldn't train it by color or gray level alone. Imagine how difficult it would be to isolate one torso dressed in a shirt with wide horizontal stripes and another one dressed in a camouflage shirt.

Like I said previously, this is not a trivial problem whatsoever. If ...

jonsca commented: Excellent points +4

[QUOTE=Sandhya212;1224739]Hi,

I have code as follows wherein I pass a 2D array to a function and want to receive this array with its contents tripled.

The error I get is 'error: cannot convert 'int (*)[4]' to 'int**' in return'.
I was able to send and receive a 1D array using 'pass by value' but for 2D I hit this error. Please advice.[/QUOTE]

The most obvious solution is to [I]not[/I] return anything from the function. Since the array is passed to the triple function by reference, there is no need to return its address. You can simply pass the array to the function, modify it in place in the function, and when the function returns, the array will have been modified and its address will be the same. There is absolutely no need to return a pointer from the function. For example:

[code]

include

using namespace std;

int modify( int arr[4] )
{
for( int i=0; i<4; i++ )
arr[i] += 1;
return (int
)(arr);
}

int main()
{
int origArr[4];
memset( origArr, 0, 4 sizeof(int) ); // fill with 0's
int
newPtr = modify( origArr ); // Now it is filled with 1's
cout << ( newPtr == origArr ) << endl; // The pointer references the same location as the original array
return 0;
}
[/code]

You could instead simply do this:
[code]

include

using namespace std;

void modify( int arr[4] )
{
for( int i=0; i<4; i++ )
arr[i] += 1;
}

int main()
{
int ...

[QUOTE=caffeine;1176222]Oh, for the love of Darwin.

Thank you for restoring my sanity (and sorry for the brain fart).[/QUOTE]

caffeine commented: Thank you for being patient with my stupid mistake! +1

[code]
case 'a':
{
//Create an object and return a pointer to that object
//(I will be making many of these objects)
[B]Base::ReturnPtrToANewBaseClassObject();[/B]

``````            //push the returned pointer onto the std::list
BaseList.push_back( ptr );

cout << "Object now pushed onto list" << endl;
break;
}``````

[/code]
This is the way that you would call a static class function. Static functions allow you to call a function belonging to the class without having an instance of the class created. However, you must use the [B]static[/B] keyword when defining the function in the header file. See [URL="http://www.exforsys.com/tutorials/c-plus-plus/c-plus-plus-static-functions.html"]this[/URL] for more information.

Also, the ReturnPtr....() function returns a pointer, but you are not storing this value. You could either do this on two lines like:
[code]
Base* ptr = Base::ReturnPtrToANewBaseClassObject();
BaseList.push_back( ptr );
[/code]
or on one like
[code]
BaseList.push_back( Base::ReturnPtrToANewBaseClassObject() );
[/code]

All that being said, I think you are going down a bad road here. What you are essentially doing is creating an instance of an object with some specific value. This is exactly the function of a constructor. I would recommend that you use a constructor to accomplish this. However, I wouldn't use [B]cin[/B] inside of the constructor. Instead, in the main program ( or wherever it is needed ) i would request the input, and then pass the input string off to a constructor to create a new Base object. Something like:
[code]

Base::Base( string someStr )
{
_mystring = someStr;
}

int main()
{
string inStr;
cout << "Give me ...

Carrots commented: Thanks for helping me out. thumbsup'jpg +1

Since your 2D data is being stored in 1D arrays, all you need to do here is play indexing games. Suppose you had a matrix of MxN stored in a 1D array M*N in length. If the matrix is stored in column major order, and you need to convert it to row major order, you will have to do some copying. So, try this approach:

[icode]

1. Given an MxN ( M=width, N=height ) Matrix ( mat0 ) stored in column major order in a 1D array ( arr0 ) of length M*N
2. Create another 1D ( arr1) array of the same size (M*N) that will contain the matrix when it is converted to row major order
3. Iterate over arr0 using an index value ( idx0 ) beginning at index 0 to M*N ( the length of the array )
4. Compute an index ( idx1 ) into the row major matrix the column major array index ( idx0 )
5. Store arr0[idx0] into arr1[idx1]
[/icode]

To do step 3, you should take advantage of integer division and modulo properties. Namely

For row major matrices:
[icode]
row = index / width;
col = index % width;
[/icode]

For column-major indices
[icode]
row = index % height;
col = index / height;
[/icode]

Hope this helps!

[QUOTE=Fbody;1142085]Did you even read that link you posted? It doesn't [B][U]have to[/U][/B] be a struct, but you can use one that has a bool function in it. All you really need is a function that returns true when the items being compared are in proper order.[/QUOTE]

Oops. You are correct. I should have read the link more carefully.

[QUOTE=TheWolverine;1136101]
I would appreciate if someone could help me sort out how to do this with accumulate (and also then how best to raise all of the vector elements to the exponent value before submitting them to the function). If not with accumulate, I'd appreciate any advice on how to do this efficiently.
[/QUOTE]

The trick is implementing the function you pass to accumulate. Here is a demonstration that uses a vector of int pointers:

[code=c++]

include
include
include

using namespace std;

template
T adder( T init, T iter ){ return init + iter; }

int main(){
int n = 1000;
vector<int*> values( n, NULL );
for( int i=0; i<n; i++ )
values[i] = new int(i);
int init = 0;
int result = accumulate( values.begin(), values.end(), init, adder );
cout << result << endl;
return 0;
}
[/code]
The trick is that the adder function gets the init value as its first argument. The second argument is the iterator for the element to be accumulated next. In our case, this is a pointer, so we need to dereference it. I hope this helps and is the sort of solution you were looking for. Note that you could make adder a static function belonging to a class of type T.

StuXYZ commented: Clear example +3

[QUOTE=sheff_cc;1142047]Double number may have 64bits length,so it has a limit on the stored value(minus 32 times, 32 times)[/QUOTE]

There is a limit, but I'd be surprised if the OP would have to worry about going larger than [B][I]1.7 * 10 ^308[/I][/B].

Of, course, with the big numbers you lose precision in lesser significant digits, but usually with large numbers, nobody cares about that.

[QUOTE=n1337;1139713]
So the question is... how do you extract the column and row vectors using your particular representation of a matrix?[/QUOTE]

You wrote a bunch of information that didn't answer the question and then re-asked to OP's question.

OP: you can think of representing a 2D matrix in 1D as a counting operation. Basically, you count from zero to the # of elements in the column, then go back to zero and start again. This should remind you of a modulo operation, where as you increment an integer, it wraps back to 0 at the divisor. So:
[icode]
6%8 == 6
7%8 == 7
8%8 == 0
9%8 == 1
10 %8 == 2
[/icode]
This is half of the method you would use to convert between 1D indices and 2D indices. The other half can be defined by using integer division. Integer division will basically tell you how many times you have counted up to some number ( like the # of elements in a column ).
[icode]
6/8 == 0
14/8 == 1
22/8 == 2
30/8 == 3
[/icode]
Now, if you can combine an integer modulo opeation with an integer division operaton, you can extract 2D indices from 1D indices. I don't want to answer your question completely ( because it might be homework ), but I think this should point you in the right direction.

[QUOTE=kumar2884;1133130]Hi

Currently i am using Matlab, but i need to convert the matlab code to C/C++, So that it will be sue full for a mobile application.
But the problem is i am not sure where we can use Open CV for such application.[/QUOTE]

I found this on google: [url]http://alexkarpus.com/opencv/[/url]. Looks like using OpenCV for mobile devices is very doable.

Look at the[URL="http://opencv.willowgarage.com/wiki/"] OpenCV website[/URL], the [URL="http://tech.groups.yahoo.com/group/OpenCV/"]OpenCV Yahoo User Group[/URL], and google in general for some good examples of how to use OpenCV.

Nick Evan commented: Sounds good +12

First of all, you need to have the image data stored in some sort of serially accessible data structure. Lets suppose that you have the image data in an array of floats.

Next, you need to scale your data to a specific range. Often, this range is the interval [0,1.0). However, some activation/squashing function combinations do better with different input ranges. It may be more appropriate to choose the (-1.0, 1.0 ) interval. Your choice of scaling method could also be significant. Often, you will want to normalize the pixel values to a specific range. The easiest approach is to scale each value by 1.0 / MaxPixelValue ( usually 1.0 / 255 ). However, it is usually better to do a min/max nomralization.

Once you have your normalized image data in a serially accessible data structure, all you need to do is step through it and assign each pixel value to an input node (or, with some ANNs, pass the array to the train/classify function).

[B]One thing you should be sure to note:[/B] Neural nets are extremely sensitive to affine transformations of image data. So, rotations, displacements, and scalings will confuse your ANN. To combat this problem, you either need a method to correct affine transformations [B]before[/B] classification, or you need a method to convert raw pixel data into another form that is invariant to these affine transformations.

Some of your words have trailing spaces. This results in some un-fun!
[icode]
Mystery Word : numerical*
Guessed letters : e,i,t,s,l,a,o,d,n,m,u,r,c,y,z,b,f,g,h,j,k,p,q,v,w,x,
Guess number : 26

Enter a letter :
[/icode]
I was having fun until I realized that numerical didn't fill the word. What begins with numerical and ends in one more letter? numericaly?

[QUOTE=Elimirza;1125211]any help[/QUOTE]
[URL="http://mathworld.wolfram.com/Sum.html"]Sum[/URL]
[URL="http://mathworld.wolfram.com/Variance.html"]Variance[/URL]
Perhaps try to help yourself some. There is this really great resource for programmers to find information to help solve their problems. It's called [URL="http://www.google.com"]google[/URL].

Salem commented: Nice +19

I read your first lesson. It was....interesting. Here are a few highlights
[quote]
You can name your variable anything (as long as it doesn't correspond with any keywords used in the C++ language; no spaces are allowed). You put a semicolon at the end of the line.
[/quote]
So, i can name my int variable [icode]int #1Awesome.variable/value;[/icode]?
[quote]
The all powerful #define is the last thing you will learn in this lesson. You can use this to set text commands. Almost like macros.
[/quote]
Almost like?

You really have an odd assortment of information here. Some of it is correct and succinct. Some of it, you launch into way too much detail about things that a beginner needs to know nothing about. Some of it is misleading. Some of it is just plain wrong.

The best teaching tutorials I have seen take small, compileable programs and break down what is happening at every step along the way. I appreciate what you are trying to do, but if you are going to shepherd the lambs, take them to meadows you know well.

VilePlecenta commented: #lol^â–€Ã¦ +0

[QUOTE=doddware;1129087]
We can't use the optimizer (managerial decision, because people don't know how to use [COLOR="Red"]volatile[/COLOR], a different discussion). This is the first time I've ever seen this and I'm interested in any reasoning why we shouldn't just remove it to eliminate code bloat.[/QUOTE]

It sounds like you might be doing some parallel work here, perhaps. "Guaranteeing" the state of a register also sounds like some sort of a hack to avoid a race condition, perhaps. In serial code, the [icode]!!someVar[/icode] should have no logical effect (especially in the case of native types where, regardless of the type, it's underlying bits are just getting flipped twice). For some reason, this idea is ringing a bell, though I can't place it.

Still, it seems like a hack no matter what. Ensuring thread safety should always be done explicitly using thread-safe constructs provided by the language [B]for that specific purpose[/B].

I would suggest that you create some unit tests for a piece of code using this convention and assure yourself that double negating a byte is indeed semantically null.

Did you know that asking someone else to do your homework for you is cheating? Did you know that you will learn [B]nothing[/B] by cheating on your homework? Did you know you are flushing your money down the toilet if you cheat on a college class that you are paying to take? I hope to god you aren't a Computer Science major.