Search:

Type: Posts; User: hamster_nz

Page 1 of 9 1 2 3 4

Search: Search took 0.01 seconds.

  1. Replies
    16
    Views
    214

    Or just use addition... #include ...

    Or just use addition...



    #include <stdio.h>
    int main(int argc, char *argv[]) {
    float f;
    int x;
    int e = 0;
  2. Replies
    16
    Views
    214

    But.... Why? I mean, it is possible, and I can...

    But.... Why?

    I mean, it is possible, and I can do it, but why do you want to?

    And why the restriction on what elementary operators you can use?
  3. Replies
    5
    Views
    340

    Here is using the "read" and "write" system calls...

    Here is using the "read" and "write" system calls directly.

    Note that this program needs no header files, as it is accessing the Linux system calls directly rather than using any library functions...
  4. Replies
    5
    Views
    340

    To write an integer to a file int i; ...

    To write an integer to a file



    int i;
    fwrite(&i,sizeof(i),1,f);


    To read an integer from a file
  5. Replies
    4
    Views
    301

    Here's a state machine for traffic lights. It...

    Here's a state machine for traffic lights. It might give you ideas:



    #include <stdio.h>
    #include <unistd.h>


    enum State { state_all_stop, state_NS_go, state_NS_stopping, state_WE_go,...
  6. Replies
    4
    Views
    301

    I don't usually support gambling, but in this...

    I don't usually support gambling, but in this case I bet you are asking us to do your homework for you.
  7. Replies
    15
    Views
    536

    Which header file is DBL_MANT_DIG defined in? ...

    Which header file is DBL_MANT_DIG defined in?

    Ah, found it - float.h

    That is a pretty good solution.
  8. Replies
    15
    Views
    536

    This isn't perfect and isn't portable, but how I...

    This isn't perfect and isn't portable, but how I would think about it.

    Note I haven't tested it on multiple platforms



    #include <stdio.h>
    #include <stdlib.h>
    #include <stdint.h>
    #include...
  9. Replies
    15
    Views
    536

    It's pretty inefficient, and I'm not so sure that...

    It's pretty inefficient, and I'm not so sure that "range == 0" is a good idea.

    If doing this, I would generate random bits for the memory holding the double, then explicitly mask and set the sign...
  10. Replies
    4
    Views
    432

    It looks like you are not checking that you are...

    It looks like you are not checking that you are correctly opening the output file



    dst = fopen(obuf, "w+");


    You should check to see if dst is not NULL.
  11. Replies
    4
    Views
    432

    Even just enabling warnings on your compiler will...

    Even just enabling warnings on your compiler will help...



    gcc -o main main.c -Wall -pedantic -O4
    main.c: In function ‘main’:
    main.c:24:18: warning: implicit declaration of function ‘fatal’...
  12. Replies
    8
    Views
    529

    ... just to be sure...

    ... just to be sure...
  13. Can you show where you open the file to read it?

    Can you show where you open the file to read it?
  14. There is one more number between 1.0-DBL_EPSILON...

    There is one more number between 1.0-DBL_EPSILON and 1.0:



    #include <float.h>
    #include <stdio.h>


    void printhex(void *x, size_t s) {
    for(size_t i = 0; i < s; i++)
  15. Me? I would most likely do what I did when I...

    Me? I would most likely do what I did when I needed random numbers that were inside a sphere. Generate random numbers between -1 and 1 (inclusive), and if it s >= 1.0 or <= -1.0 then just loop and...
  16. So I've got this 10GB file of 'baseband' data....

    So I've got this 10GB file of 'baseband' data. It's a 2-channel WAV file, but rather than left and right stereo it's what is called I+Q. It's called baseband because rather than a radio signal at...
  17. If it is an integer -1 < x < 1 then it doesn't...

    If it is an integer -1 < x < 1 then it doesn't leave many options....
  18. Replies
    1
    Views
    414

    The first thing I see is that >= 0should just be...

    The first thing I see is that >= 0should just be > 0.
  19. Currently I am working on decoding the telemetry...

    Currently I am working on decoding the telemetry of the Falcon 9 second stage.

    I've got a raw 10GB data file of the baseband signal, so am building on my DSP skills to convert it into the binary...
  20. Replies
    2
    Views
    460

    One nice project would be a multithreaded prime...

    One nice project would be a multithreaded prime number finder.

    It has quite a few interesting features...
  21. I reformatted your code's intentation void...

    I reformatted your code's intentation


    void main (void)
    {


    //SET UP
    ANSEL = 0; //turn off all analog inputs
    ANSELH = 0;
  22. That code is completely unencumbered, so anybody...

    That code is completely unencumbered, so anybody can use it however you like. Pfease feel free to use it in a MIT Licensed project.

    Oh, I don't know about PNG files, but BMP files are pretty...
  23. With a seed of zero, after a while it gets stuck...

    With a seed of zero, after a while it gets stuck in a loop of repeating 35,246 values.

    If you are feeling idle, try this:



    static uint32_t my_rng(unsigned int x) {
    unsigned int b;
    b...
  24. I hope I haven't coded it wrong.... ...

    I hope I haven't coded it wrong....



    #include <stdio.h>
    #include <limits.h>
    #include <time.h>


    #define bitsof(x) (sizeof(x)*CHAR_BIT)
  25. Replies
    5
    Views
    478

    Here's two writers, one reader. Expand as needed....

    Here's two writers, one reader. Expand as needed.



    #include <stdio.h>
    #include <string.h>
    #include <sys/types.h>
    #include <unistd.h>
    #include <errno.h>
Results 1 to 25 of 213
Page 1 of 9 1 2 3 4