CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com

Search:

Type: Posts; User: wolle

Page 1 of 27 1 2 3 4

Search: Search took 0.03 seconds; generated 55 minute(s) ago.

  1. Thread: complex signal

    by wolle
    Replies
    1
    Views
    350

    Re: complex signal

    C++ has a standard library to handle complex numbers,

    https://en.cppreference.com/w/cpp/numeric/complex

    Say you have,

    f(t) = exp^(j*omega*t)

    Note that the imaginary unit j plays a role in...
  2. Replies
    3
    Views
    300

    Re: Set to coordinates to centre of grid

    My code is logically the same as yours. If your code is wrong, so is mine. Your problem description indicates you have a working solution and now want help making your code become "neater".
  3. Replies
    3
    Views
    300

    Re: Set to coordinates to centre of grid

    I do not know what you mean by neater, but this is another way of assigning values to devy and devx,



    if (_num <= 3) {
    devy = 1;
    devx = _num - 2;
    } else if (_num <= 6) {
    devy = 0;...
  4. Replies
    1
    Views
    281

    Re: I'm new in Golang

    What is wrong with VS Code? It is considered one of the best. Maybe you did not download the Go extension. Why not give it another Go :)

    https://code.visualstudio.com/docs/languages/go

    Anyway,...
  5. Replies
    1
    Views
    446

    Re: Tournament Round robin to bracket

    Could you please explain what is wrong with the order of the matches in the examples you have presented?

    I cannot see anything strange in particular. Or is it maybe, that those who play their...
  6. Replies
    6
    Views
    2,045

    Re: Sudden problem with std::vector

    But, it only works if the function itself is executable at compile-time. If not, you still need to use an std::vector.
  7. Replies
    6
    Views
    2,045

    Re: Sudden problem with std::vector

    It will work (in this case) if the function is declared constexpr.
  8. Replies
    4
    Views
    796

    Re: Float point number simple arithmetic.

    In addition to my post #4.

    Not all decimal numbers have a finite digital representation. This includes 0.1, which requires an infinite number of bits. So when you assign 0.1 to a single-precision...
  9. Replies
    4
    Views
    796

    Re: Float point number simple arithmetic.

    A single-precision FP has 6-7 significant decimal digits, and a double-precision FP has 15-18. A good rule is to consider the significant digits only. The range of significant digits in an FP starts...
  10. Re: Why is my single thread code is faster than my multhread code?

    That may speed things up on the CPU side, but you probably should do something to that effect on the GPU side too. Maybe by pooling the command buffers,
    ...
  11. Re: Is it safe to locally use arrays, vectors and calloc when multi-threading

    I understand there may be company restrictions. But if you are free to choose, I recommend you update to the latest Visual Studio version and the latest C++ standard. With a reasonable delay, of...
  12. Re: Is it safe to locally use arrays, vectors and calloc when multi-threading

    I agree with the previous posters, at least if you use C++ version 11 or later.

    C++ 11 was a game-changer. Especially concurrency got a much-needed overhaul. Why should you not be able to use...
  13. Thread: Finding Doubles

    by wolle
    Replies
    12
    Views
    1,009

    Re: Finding Doubles

    I posted a solution strategy to this problem quite some time ago now,

    https://forums.codeguru.com/showthread.php?562663-Birthday-is-no-problem&highlight=birthday+problem

    Today, I can just...
  14. Thread: Finding Doubles

    by wolle
    Replies
    12
    Views
    1,009

    Re: Finding Doubles

    Say you draw numbers at random from a range of equally likely numbers. At some point, all numbers have come up at least once. After that, all drawn numbers will be duplicates. With N numbers in the...
  15. Thread: Tutorials

    by wolle
    Replies
    8
    Views
    576

    Re: Tutorials

    The C++ guidelines may not fit the bill perfectly, but it does demonstrate modern C++ usage (according to Stroustrup and Sutter, two prominent figures in the evolution of C++),
    ...
  16. Thread: Finding Doubles

    by wolle
    Replies
    12
    Views
    1,009

    Re: Finding Doubles

    Duplicity is a relative property between two entities. To compare the current entitity in a sequence with previous entities, one must store them somewhere. Unless, of course, duplicity is an...
  17. Thread: Finding Doubles

    by wolle
    Replies
    12
    Views
    1,009

    Re: Finding Doubles

    Then I suggest you use an std::unordered_set,

    https://en.cppreference.com/w/cpp/container/unordered_set

    You insert each new random integer into the unordered_set using the insert function. You...
  18. Thread: Finding Doubles

    by wolle
    Replies
    12
    Views
    1,009

    Re: Finding Doubles

    Maybe you mean duplicates? Do you want to avoid them? One method is to add each new random number to an std::vector after making sure it is not already in there. Another method is to add the random...
  19. Replies
    10
    Views
    938

    Re: wait .. no blocking

    I often use a thread-safe producer-consumer queue for this kind of situation. The producer thread pushes information on the queue and the consumer thread pops it, either by active polling or waiting...
  20. Thread: array of objects

    by wolle
    Replies
    14
    Views
    1,385

    Re: array of objects

    The problem is that MyClass is not copyable because of the heap-allocated array held by the arr-pointer. And, as mentioned in #11, it gets copied here (underlined),



    myThs[i] =...
  21. Replies
    4
    Views
    557

    Re: threads and function call

    The Add function itself is thread-safe in the sense that it is reentrant in the right way,

    https://en.wikipedia.org/wiki/Reentrancy_(computing)

    It means you can call it pretty much as you like...
  22. Re: Is there a function intended to split strings by a delimiter in VC++?

    Yes, I wish I had come up with it myself :).

    I found it in the answer here,

    https://stackoverflow.com/questions/48402558/how-to-split-a-stdstring-into-a-range-v3-of-stdstring-views
  23. Re: Is there a function intended to split strings by a delimiter in VC++?

    Even simpler still. I found a way to get rid of the temporary string.

    No string constructor accepts the loop variable e directly. But e can deliver the starting address and length of a char...
  24. Re: Is there a function intended to split strings by a delimiter in VC++?

    I guess we need to be patient. Rome wasn't built in one day!
  25. Re: Is there a function intended to split strings by a delimiter in VC++?

    The code in my post #4 is directly from cppreference.com so either they or VS 2019 has it wrong.

    Anyway, using your suggestion I got this to work in VS 2019 (latest download),



    #include...
Results 1 to 25 of 674
Page 1 of 27 1 2 3 4





Click Here to Expand Forum to Full Width

Featured