Search:
Type: Posts; User: Synthetic Being
Search:
Search took 0.05 seconds.
-
April 14th, 2013, 07:09 AM
You should use unformatted input with binary data, i.e.
"byte = stream.get();" instead of "stream >> byte;".
-
November 25th, 2009, 03:35 AM
That's not surprising, considering that arithmetic shift to the right means the sign bit will be duplicated for negative numbers. This means you can shift A negative number and expect rational...
-
December 11th, 2008, 02:49 PM
Intuitively, less than O(n) for searching an unordered array is not possible. You can't possibly tell for certain that a specific item does not exist unless you look at all of them.
Fortunately,...
-
October 10th, 2008, 10:44 AM
Previous posters have a point.
Your first problem is that you haven't fully defined your problem, possibly not even to yourself and definitely not to us. Start by explaining the definition of your...
-
September 1st, 2008, 08:39 AM
Well, something like this is easy to cook up so you might as well give it a go and see if the slowdown vs. memory savings tradeoff is worthwile. If the array is heavily accessed, there might even be...
-
November 5th, 2007, 04:00 AM
IMO, more information is needed before any assessment about the relative efficiency of different choices can be made.
What probably matters most is how often these bits are accessed and if they...
-
June 15th, 2007, 01:26 AM
The ternary conditional operator is technically a branching construct provided the compiler can't/isn't allowed to use any branch replacement instructions. By using these, the compiler can completely...
-
This is a classic problem. There are different solutions depending on how large your group of source numbers is and how many you want to choose. In every solution one rule stands however: Every...
-
December 5th, 2006, 04:11 AM
Btw, that power function has O(e) complexity. Here's an O(log(e)) power function for unsigned integers.
unsigned int iPow(const unsigned int x, const unsigned int p) {
if(p < 2) {
return...
-
February 1st, 2006, 05:39 AM
Also, it's sufficient just to calculate the squared distance X*X + Y*Y for each coordinate. Taking a square root here is unnecessary.
-
December 25th, 2005, 03:39 AM
You're welcome.
By definition, a tail recursive function is one where the result of a recursive function call is immediately returned, so there's no processing to be done for the return value and...
-
December 24th, 2005, 06:29 PM
How about using a reference to a vector as a parameter instead of the vector itself? Not only is it massively faster, but the compiler should recognise tail recursion in this specific case and turn...
-
December 20th, 2005, 07:50 AM
In P4 'Willamette' and 'Northwood', inc/dec instructions have a latency of 1 cycle, while add/sub have a latency of only 0.5 cycles. In all other current x86 implementations they are of equal speed.
-
December 20th, 2005, 04:12 AM
There isn't a lot of sense in reducing the number of instructions, since small size doesn't necessarily equal fastest code. Speed is kind of the point with asm nowadays, unless we're talking about...
-
October 31st, 2005, 08:11 AM
"Vector<bool> Considered Harmful"? Are there any other problems than the obvious performance/efficiency-related?
Perhaps I didn't understand your cunning plan, but how does this reduce the peak...
-
October 31st, 2005, 01:39 AM
vector<bool>
bitset
In theory, there doesn't seem to be much of a difference, except that vector is more common and its syntax can often be recited from memory. Also, it doesn't require a...
-
October 30th, 2005, 04:54 PM
For problems related to printing a range of numbers in random order, random_shuffle is usually the tool of choice. In this case however, the large amount of numbers themselves take a lot of memory....
-
September 23rd, 2005, 08:13 AM
Obviously, the code isn't plain C. But what do you mean by "write an int directly"? Currently, an int is read from the table and then written to the buffer.
Since the bytes are written in the...
-
September 23rd, 2005, 04:29 AM
Expanding bits to chars one at a time isn't probably the most efficient way to do this. Considering that int is supposed to be the fastest basic type, it makes sense to use that as the basic unit....
-
Rounding positive numbers is easy, just one more bit of accuracy is needed to know whether the result was at least 0.5 above or not. So we multiply by 2 before division and divide afterwards.
...
-
January 5th, 2005, 07:17 AM
I think the numeric values of 'true' and 'false' weren't in doubt but rather if those values were actually returned. In standard C++, this is obviously the case. In C99 the return type is defined as...
-
January 5th, 2005, 04:28 AM
No, there isn't. The return type from relational and equality operators is bool, which says in the C++ standard. Only an uninitialised bool could have values other than 0 or 1.
-
January 3rd, 2005, 06:28 AM
Now that this old thread has been lifted, I might add some fresh comments on the issue.
There are many problems related to application performance. Branches are a relatively minor one when...
-
January 3rd, 2005, 05:34 AM
Yep. That answer was written in the form of the first message in the thread, not the later ones. Could've clarified that, but then again I didn't make any claims. ;)
-
January 2nd, 2005, 05:36 AM
1 0 1 0 1 0 1 0 0
1 1 1 0 1 1 1 0 1
0 1 1 1 1 1 0 1 1
So, I assume it's these groups you wanted to find. This could be done using a flood fill, either stack based or recursive.
The...
|
Click Here to Expand Forum to Full Width
|