Search:

Type: Posts; User: Sir Galahad

Page 1 of 10 1 2 3 4

Search: Search took 0.01 seconds.

  1. Thread: FIFO Queue

    by Sir Galahad
    Replies
    8
    Views
    162

    Consider the state of this object: struct...

    Consider the state of this object:



    struct Queue q;


    The object's members are most likely "pointing" to invalid memory addresses. The queueInit function is simply defined to ensure that the...
  2. No, divide and conquer implies recursion. This...

    No, divide and conquer implies recursion. This would be the "iterative approach".
  3. The common prefix length can be computed pretty...

    The common prefix length can be computed pretty efficiently without all of those expensive allocations.



    #include "stdlib.h"

    size_t common_prefix_s(const char* s1, const char* s2)
    {
    ...
  4. Replies
    15
    Views
    638

    LOL. Yeah I just realized that while I was on my...

    LOL. Yeah I just realized that while I was on my bike ride. Meh...
  5. Replies
    15
    Views
    638

    Well I stand corrected! On a side note,...

    Well I stand corrected!

    On a side note, wouldn't it be nice if Stroustrup had made C++ completely backward-compatible with C? Just seems like it would have made things easier in the long run...
  6. Replies
    15
    Views
    638

    Well there was nothing wrong with that code and...

    Well there was nothing wrong with that code and certainly no good reason to raise an issue about it. Remember, languages are just tools...
  7. Replies
    15
    Views
    638

    Nevertheless most C constructs CAN be safely used...

    Nevertheless most C constructs CAN be safely used in C++ programs. As long as it compiles and doesn't introduce problematic side-effects, why not?
  8. Replies
    15
    Views
    638

    Wasn't the code that aghast posted valid C++?

    Wasn't the code that aghast posted valid C++?
  9. Good advice!

    Good advice!
  10. Replies
    15
    Views
    647

    So a very talented mathematician showed me how...

    So a very talented mathematician showed me how this can actually be done.

    The main idea is to repeatedly apply a calculation in such a way that it causes an "overflow" in a given fixed-precision...
  11. Replies
    15
    Views
    647

    Or maybe this? Repeatedly subdivide into 256...

    Or maybe this? Repeatedly subdivide into 256 "spaces" (in single byte chunks) until enough "bits of the mantissa" have been processed?



    #include "float.h"
    #include "limits.h"

    /*
    Generate...
  12. Replies
    15
    Views
    647

    Thanks for all the useful suggestions everyone! I...

    Thanks for all the useful suggestions everyone! I do wonder if the mantissa bits could somehow be "detected" (computed) without any prior assumptions? If so then these methods could be used as a...
  13. Replies
    15
    Views
    647

    I wouldn't use rand() for anything other than a...

    I wouldn't use rand() for anything other than a toy program, I was just giving an example of the interface I was thinking of.

    The platform independant part I was referring to was how the numbers...
  14. Replies
    15
    Views
    647

    Nice! One issue with that though is being...

    Nice! One issue with that though is being somewhat limited by the RAND_MAX term. Maybe constructing the number from a string of bits to fill the largest integral machine type would be better?

    I...
  15. Replies
    15
    Views
    647

    Would you mind giving an example of how that...

    Would you mind giving an example of how that might be done in a platform neutral manner? I know my way is rather inefficient, I just couldn't figure how else to do it.



    Good point! It was just...
  16. Replies
    15
    Views
    647

    More thoughts on random floats

    I was reading this interesting thread about generating random ranges of floating point values.

    What about closed ranges? I was wondering if a simple binary partitioning approach could be used.
    ...
  17. Ah, in that case maybe the wmctrl...

    Ah, in that case maybe the wmctrl command? (Example usage discussed here.)
  18. Something like this maybe: cat $1 $2 >...

    Something like this maybe:



    cat $1 $2 > .tmp && mv .tmp $2


    Running the script:
  19. It's been a while since I've done any WIN32...

    It's been a while since I've done any WIN32 programming (I assume that what you're talking about here) so not 100% sure this is correct but from what I remember anyway. If the WM_CREATE message...
  20. Fancy input is certainly a nice feature, though...

    Fancy input is certainly a nice feature, though not usually really necessary in most cases. A more simplified format might help get things up and running in the meantime.

    Example using command...
  21. Replies
    14
    Views
    806

    Explicitly freeing a NULL pointer is pretty much...

    Explicitly freeing a NULL pointer is pretty much nonsensical anyway. There's nothing to delete!
  22. I may have been overthinking things just a bit....

    I may have been overthinking things just a bit. The most important thing seems to be the checking for all potential continuation sequences and such. I put together a simple verification program which...
  23. Replies
    8
    Views
    450

    Nice!

    Nice!
  24. Whoops, forgot the bounds checking step! ...

    Whoops, forgot the bounds checking step!




    bool output_utf8(const byte* utf8, size_t length) {
    const byte* end = utf8 + length;
    while (utf8 < end) {
    // Code Point Range Byte 1 ...
  25. That helps! Here's the current version then: ...

    That helps! Here's the current version then:





    #include <locale.h>
    #include <stdbool.h>
    #include <stdio.h>
    #include <stdlib.h>
Results 1 to 25 of 237
Page 1 of 10 1 2 3 4