Search Results - CodeGuru Forums
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums


Type: Posts; User: Synthetic Being

Page 1 of 2 1 2

Search: Search took 0.01 seconds.

  1. Re: reading bytes without bit loss

    You should use unformatted input with binary data, i.e.
    "byte = stream.get();" instead of "stream >> byte;".
  2. Re: Arithmetic shift (signed shift) not working in GCC compiler

    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...
  3. Re: really fast array search or array sorting algorithm

    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.

  4. Replies

    Re: pixel counting in c++

    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...
  5. Replies

    Re: Something about integers

    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...
  6. Re: which way is more efficient to check bit value

    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...
  7. Replies

    Re: comparison function

    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...
  8. Re: Algorithm to return an unused Random Number

    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...
  9. Replies

    Re: Power Operator + Abs Function

    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) {
  10. Replies

    Re: Pick k points closest to origin

    Also, it's sufficient just to calculate the squared distance X*X + Y*Y for each coordinate. Taking a square root here is unnecessary.
  11. Re: What is the cost of recursive function?

    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...
  12. Re: What is the cost of recursive function?

    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...
  13. Replies

    Re: How fast is it?

    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.
  14. Re: Check this little assingment of arithmatic operation...

    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...
  15. Replies

    Re: Maximum size of an array

    "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...
  16. Replies

    Re: Maximum size of an array


    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...
  17. Replies

    Re: Maximum size of an array

    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....
  18. Replies

    Re: Checking every bit in a variable FAST

    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...
  19. Replies

    Re: Checking every bit in a variable FAST

    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....
  20. Re: Proper rounding when performing divisions [C++]

    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.

  21. Re: Implementing If-then-else without branching

    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...
  22. Re: Implementing If-then-else without branching

    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.
  23. Re: Implementing If-then-else without branching

    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...
  24. Replies

    Re: float point bitwise operations

    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. ;)
  25. Replies

    Re: Finding groups of 0's

    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.

Results 1 to 25 of 31
Page 1 of 2 1 2

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

This a survey!

HTML5 Development Center