Search:

Type: Posts; User: hamster_nz

Page 1 of 13 1 2 3 4

Search: Search took 0.01 seconds.

  1. Replies
    4
    Views
    330

    I think you need to do something like this: ...

    I think you need to do something like this:



    #include <stdio.h>
    #include <stdlib.h>


    typedef struct
    {
  2. Replies
    4
    Views
    330

    I compiled with warnings on - be mindful that C...

    I compiled with warnings on - be mindful that C arrays start at element 0!



    main.c:64:80: warning: array subscript 3 is above array bounds of ‘PPMHead[3]’ {aka ‘struct <anonymous>[3]’}...
  3. Replies
    1
    Views
    239

    Had a quick look at the compare issue. If only...

    Had a quick look at the compare issue.

    If only one of the numbers is positive, it's the largest
    If both are positive, you need to return big_cmp_abs()
    If both are negative, you need to return -1...
  4. Replies
    20
    Views
    1,036

    Does this qualify... int...

    Does this qualify...



    int my_memorized_func(int a, int b, int c, int d) {
    static int results[20][20][20][20] = {0};
    if(results[a][b][c][d] == 0)
    results[a][b][c][d] =...
  5. Replies
    1
    Views
    230

    You need to case the "vold *" to a "something *"...

    You need to case the "vold *" to a "something *" so the compiler knows what sort of data you are accessing (e.g. char, short, int, long, float double, a structure...)



    *((int *)ptr) = 12;
  6. Replies
    4
    Views
    439

    Ah well, I'll show myself out then...

    Ah well, I'll show myself out then...
  7. Replies
    4
    Views
    439

    The technique I would use is quite an advanced...

    The technique I would use is quite an advanced one - a finite state machine.

    It is where you keep track of where you are in the expression (i.e. expecting an operator or a number) and act...
  8. Replies
    20
    Views
    1,036

    opps... sorry for the error in my code. Glad...

    opps... sorry for the error in my code. Glad john.c picked it up.

    Oh, and yes, I have pretty much the same picture that john.c drew scribbled on a bit of scrap paper. The hard bit is deciding...
  9. Replies
    20
    Views
    1,036

    If you draw a picture of what can follow what (a...

    If you draw a picture of what can follow what (a state diagram), and allow for the fact that you have to end where you can start (so it is a loop) you get



    necklace_length( t, r, s, e )
    if...
  10. Replies
    10
    Views
    776

    Hi Alin, I've written a PNG file decoder...

    Hi Alin,

    I've written a PNG file decoder earlier this year. Here's how it works,

    There is a small wrapper that has the signature, image size and some other details in it, including color depth...
  11. Replies
    8
    Views
    901

    Here's my equivalent: int32_t...

    Here's my equivalent:



    int32_t a=0,b=0,c=0;
    if(x > bytes_per_pixel) {
    a = img->scanline[y]->data[x-bytes_per_pixel];
    }
    if(y >...
  12. Replies
    5
    Views
    674

    Maybe you might want to add a couple of...

    Maybe you might want to add a couple of functions, making you 'main()' function look something like this:



    int main ()
    {
    int p[5]={15,30,28,19,61};


    printArray("Before shift", p,...
  13. Replies
    8
    Views
    901

    expected = 000003F7, actual = CF2F0849 ?

    expected = 000003F7, actual = CF2F0849

    ?
  14. The printf/scanf format strings.

    The printf/scanf format strings.
  15. You are seeing 3 because overflows are not...

    You are seeing 3 because overflows are not errors.

    Think of it like being 'clock' arithmetic, where 11:00 plus 3 hours equals 2:00.

    For 8-bit unsigned numbers 0 follows after 255.
  16. You have a typo. It is uint8_t not unit8_t.

    You have a typo. It is uint8_t not unit8_t.
  17. Replies
    3
    Views
    568

    Just by eyeballing them I can tell that they are...

    Just by eyeballing them I can tell that they are good. They start at "all zeros" and end at "all ones".

    But will supply a table when I finish work (in about 9 hours or so).
  18. Thread: adler32

    by hamster_nz
    Replies
    2
    Views
    402

    For a given block of data, prior_key is ...

    For a given block of data, prior_key is 0x00000001 for the first time the function is called, and from then on whatever was returned by this function the last time it was called.
  19. Replies
    4
    Views
    560

    The usual way to scale an n-bit value into a...

    The usual way to scale an n-bit value into a 2n-bit value is to multiply by 2^n+1.

    e.g. from a 4-bit value to an 8-bit value is to multiply by 17.

    Coding it is usually a shift-and-add:



    ...
  20. Replies
    125
    Views
    10,409

    Here's 37 lines that does those 200 lines...

    Here's 37 lines that does those 200 lines correctly. Note how everything is handled identically.



    static const int32_t lut_code[19] = { 0, 1, 2, 3, 4, 5, 6, 7, 8,...
  21. Replies
    125
    Views
    10,409

    You still need to adjust the rest of your code...

    You still need to adjust the rest of your code accordingly too.

    This change means that you will only need to add entries to your table in one place in your code, rather than handling those 16 and...
  22. Replies
    125
    Views
    10,409

    I think you might end up with cleaner code if you...

    I think you might end up with cleaner code if you realized that



    ZLIB_IMPLIED implied_type_data =
    {
    /* get extra bits */
    {
    0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0,...
  23. Replies
    125
    Views
    10,409

    Looking at your output, the first table seems...

    Looking at your output, the first table seems perfect.

    The second one has literals that should not occur. 386? 404? 382?



    code_symbols[ 0]: _tt = false, src = 138, lit = 283, use = ...
  24. Replies
    20
    Views
    1,634

    It is very hard to track down if you mave a...

    It is very hard to track down if you mave a memory leak in your code if it doesn't free all resources before exiting.

    Also, usually tidying up before exiting can involve such things as writing...
  25. Replies
    20
    Views
    1,634

    I strongly disagree with this advice....

    I strongly disagree with this advice. "Maintaining a lost of allocated memory blocks" is exactly what malloc(), free(), realloc() and so on do on the inside, and usually do it in a far more nuanced...
Results 1 to 25 of 316
Page 1 of 13 1 2 3 4