# Search:

Type: Posts; User: hamster_nz

Page 1 of 9 1

1. ## Thread: 2d matrix beginner.

by hamster_nz
Replies
8
Views
293

### ... just to be sure...

... just to be sure...
2. ## Thread: Converting text files from Windows to Linux in C

by hamster_nz
Replies
3
Views
235

### Can you show where you open the file to read it?

Can you show where you open the file to read it?
3. ## Thread: How to generate a random number in the interval of -1 and 1?

by hamster_nz
Replies
17
Views
486

### 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++)
4. ## Thread: How to generate a random number in the interval of -1 and 1?

by hamster_nz
Replies
17
Views
486

### 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...
5. ## Thread: What sorts of programs in C do you develop now?

by hamster_nz
Replies
6
Views
476

### 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...
6. ## Thread: How to generate a random number in the interval of -1 and 1?

by hamster_nz
Replies
17
Views
486

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

by hamster_nz
Replies
1
Views
201

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

The first thing I see is that >= 0should just be > 0.
8. ## Thread: What sorts of programs in C do you develop now?

by hamster_nz
Replies
6
Views
476

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

by hamster_nz
Replies
2
Views
297

### 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...
10. ## Thread: Need help with a Analog and Digital Intruder alarm

by hamster_nz
Replies
1
Views
229

### I reformatted your code's intentation void...

void main (void)
{

//SET UP
ANSELH = 0;
11. ## Thread: Came back to random numbers and got decent randomness

by hamster_nz
Replies
17
Views
446

### 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...
12. ## Thread: Came back to random numbers and got decent randomness

by hamster_nz
Replies
17
Views
446

### 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...
13. ## Thread: Came back to random numbers and got decent randomness

by hamster_nz
Replies
17
Views
446

### 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)
14. ## Thread: using only one pipe for n processes

by hamster_nz
Replies
5
Views
329

### 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>
15. ## Thread: using only one pipe for n processes

by hamster_nz
Replies
5
Views
329

### Here's two writers, one reader. You should be...

Here's two writers, one reader. You should be able to take it from here...

#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
16. ## Thread: using only one pipe for n processes

by hamster_nz
Replies
5
Views
329

### Writing is realatively eays - using write() to...

Writing is realatively eays - using write() to write data to pipes are guaranteed to be atomic only if less that PIPE_BUF bytes are written at a time.

write

Because...
17. ## Thread: Quick Problem Check

by hamster_nz
Replies
21
Views
709

### I don't think 'errno' works the way this code...

I don't think 'errno' works the way this code expects...

ssize_t bytes = write( pipe, data, sizeof(void*) - byte );
#prama message "Should consider using a mutex here as this...
18. ## Thread: Quick Problem Check

by hamster_nz
Replies
21
Views
709

### One day, after many hard nights of debugging...

One day, after many hard nights of debugging where a few bytes have gone missing in the middle of a stream, or your program has terminated with a write error when you have plenty of disk space left,...
19. ## Thread: Quick Problem Check

by hamster_nz
Replies
21
Views
709

### Write does not have to write all the data...

Write does not have to write all the data requested, it can write just the first byte.

This is doubly important with pipes, where the pipe can only limited amount of data. It is possible that...
20. ## Thread: Quick Problem Check

by hamster_nz
Replies
21
Views
709

ssize_t rdpipe( pipe_t pipe, void *data )
{
return read( pipe, data, sizeof(void*) );
}

by hamster_nz
Replies
4
Views
437

### The same thing we said on discord. "

The same thing we said on discord. "<=15" should be "< 15"
22. ## Thread: Quick Problem Check

by hamster_nz
Replies
21
Views
709

23. ## Thread: Quick Problem Check

by hamster_nz
Replies
21
Views
709

### You want to close the pipes in the works when...

You want to close the pipes in the works when done, so the reader gets a POLLHUP to react to.

This is also broken:

struct worker_msg *worker_msg = NULL;
ssize_t...
24. ## Thread: Quick Problem Check

by hamster_nz
Replies
21
Views
709

### You call close() on the pipe fds even when open()...

You call close() on the pipe fds even when open() fails.

Using gotos to get out of the creation loop is a somewhat flawed pattern. Consider this instead:

for ( i = 1; i <...
25. ## Thread: Quick Problem Check

by hamster_nz
Replies
21
Views
709

### Line 406: You ask for four different poll events,...

Line 406: You ask for four different poll events, then assume there is data to be read.

Having 'worker_t' and 'Worker_t' seems problematic.

This code is problematic

...
Results 1 to 25 of 202
Page 1 of 9 1