# Search:

Type: Posts; User: hamster_nz

Page 1 of 9 1

1. ## Thread: DD to DMS

by hamster_nz
Replies
1
Views
30

### Do you have some test data and results you can...

Do you have some test data and results you can share?
2. ## Thread: Value bigger than the signed value

by hamster_nz
Replies
4
Views
79

### It's way easier than that. For 16-bit signed...

It's way easier than that. For 16-bit signed numbers the most significant bit has a 'place value' of -32768, rather than the 32768 it would have in an unsigned (or longer) value.

So 0x8011 as a...
3. ## Thread: Value bigger than the signed value

by hamster_nz
Replies
4
Views
79

### Lots of things going on here, but in summary, if...

Lots of things going on here, but in summary, if 'int' is 16 bits, and you have a overflow the answer will be wrong by 2^16, or 65536.

So what is 32785-65536? −32,751
4. ## Thread: [Beginner] strcmp in reverse order

by hamster_nz
Replies
3
Views
93

### It is quite likely that you will still have the...

It is quite likely that you will still have the same problem. You don't want to speed up the comparison, but reduce the number of comparisons.

What is the bigger problem you are trying to solve?

by hamster_nz
Replies
2
Views
108

### It is common to have two-stage locknig... Idle...

It is common to have two-stage locknig...

Idle - nobody is accessing the data.

Shared - everybody cn access, but nobody can change.

Exclusive - only one thread can access the structure.
...
6. ## Thread: Get Exponent of Float

by hamster_nz
Replies
16
Views
317

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

#include <stdio.h>
int main(int argc, char *argv[]) {
float f;
int x;
int e = 0;
7. ## Thread: Get Exponent of Float

by hamster_nz
Replies
16
Views
317

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

by hamster_nz
Replies
5
Views
373

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

by hamster_nz
Replies
5
Views
373

### 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
10. ## Thread: State machine Slot machine

by hamster_nz
Replies
4
Views
321

### 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,...
11. ## Thread: State machine Slot machine

by hamster_nz
Replies
4
Views
321

### 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.
12. ## Thread: More thoughts on random floats

by hamster_nz
Replies
15
Views
589

### 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.
13. ## Thread: More thoughts on random floats

by hamster_nz
Replies
15
Views
589

### 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...
14. ## Thread: More thoughts on random floats

by hamster_nz
Replies
15
Views
589

### 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...
15. ## Thread: C - Server/Client Example

by hamster_nz
Replies
4
Views
455

### 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.
16. ## Thread: C - Server/Client Example

by hamster_nz
Replies
4
Views
455

### 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’...
17. ## Thread: 2d matrix beginner.

by hamster_nz
Replies
8
Views
538

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

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

by hamster_nz
Replies
3
Views
430

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

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

by hamster_nz
Replies
17
Views
1,088

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

by hamster_nz
Replies
17
Views
1,088

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

by hamster_nz
Replies
6
Views
715

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

by hamster_nz
Replies
17
Views
1,088

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

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

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

by hamster_nz
Replies
6
Views
715

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

### 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...
Results 1 to 25 of 218
Page 1 of 9 1