# Search:

Type: Posts; User: Salem

Page 1 of 20 1

1. ## Thread: Get Exponent of Float

by Salem
Replies
14
Views
159

### Seems like one of those pointless exercises like...

Seems like one of those pointless exercises like add two numbers without using +

It seems the OP is lumbered with a tutor who thinks magic tricks is how you teach programming.

by Salem
Replies
9
Views
121

### > for comparison reasons we were given an...

> for comparison reasons we were given an executable file that holds an efficient code (we can't see the code).
> we are supposed to try and make an even more efficient program.
How do you compare...
3. ## Thread: Get Exponent of Float

by Salem
Replies
14
Views
159

### > while (power--) // loops 28 times - CPU...

> while (power--) // loops 28 times - CPU overloading - too expensive
So initialise b once, and do one b /= 2 for each loop iteration.

I've no idea what you're trying to prove here, except how...

by Salem
Replies
9
Views
121

### That's a why, not a what. If you want more...

That's a why, not a what.

If you want more specific help, post the text of the challenge question.
5. ## Thread: Get Exponent of Float

by Salem
Replies
14
Views
159

### That's no different to what you started with....

That's no different to what you started with.
printf("Exponent = %d\n", ((binary >> 23) & 255) - 127);

by Salem
Replies
9
Views
121

### What are you trying to show?

What are you trying to show?
7. ## Thread: Get Exponent of Float

by Salem
Replies
14
Views
159

### Bit-fields or maths. #include ...

Bit-fields or maths.

#include <stdio.h>
#include <math.h>
int main ( ) {
union {
float x;
struct {
// assumes bit fields are arranged LSB first

by Salem
Replies
9
Views
121

### > for (int i = 5; i

> for (int i = 5; i <= sqrt(num); i = i + 6)
Precalculate the square root, you're doing this every time around the loop.

> for (int i = 0; i < run_n / NUM_THREADS; ++i)
Not sure why you're not...
9. ## Thread: Cursor placement on the screen

by Salem
Replies
3
Views
97

### https://faq.cprogramming.com/cgi-bin/smartfaq.cgi?...

If you want to do more than just print text (using cout), then you'll need
Console Functions - Windows Console |...

by Salem
Replies
1
Views
99

Although having said that, some tutors seem to like that kind of stuff.

The only semi-useful comment would be the one "/* These...
11. ## Thread: What am I overlooking with my library?

by Salem
Replies
26
Views
479

### > qsort( maps->buff, maps->size, sizeof(struct...

> qsort( maps->buff, maps->size, sizeof(struct paw_map), paw_compare_maps );
Your size should be the number of elements, not the number of bytes.
12. ## Thread: file .txt and vector

by Salem
Replies
2
Views
192

### What sort of problems are you having? (we don't...

What sort of problems are you having? (we don't know, you didn't post code).

How far have you got?
- open and close the file
- read one word from the file and print it using printf
13. ## Thread: What am I overlooking with my library?

by Salem
Replies
26
Views
479

### So how does that differ from all the other public...

So how does that differ from all the other public functions in your other source files?

Does 'nm ./lib/libpaw.so' tell you anything about what symbols are present?
14. ## Thread: There is the equivalent \$Header\$, \$Date\$, \$log\$ of CVS in Git for C source code ?

by Salem
Replies
6
Views
319

### If you want to know what happened on a per file...

If you want to know what happened on a per file basis, just type
git log path/to/file
It will tell you just those commits which affected that file.

Similarly for some sub-directory, like the one...
15. ## Thread: What am I overlooking with my library?

by Salem
Replies
26
Views
479

### > /usr/bin/ld: chkpaw.c:(.text+0x5d): undefined...

> /usr/bin/ld: chkpaw.c:(.text+0x5d): undefined reference to `paw_unload_app'
This usually means
- you didn't implement that function.
- you implemented it, but it's static (or hidden) for some...
16. ## Thread: Measuring the length of a string with a for loop

by Salem
Replies
3
Views
222

### for (i = 1; str[i] != '\0'; ++i); Is no...

for (i = 1; str[i] != '\0'; ++i);

Is no different to this, having gone round the loop once.
for (i = 0; str[i] != '\0'; ++i);

Compare with

int main(void) {
unsigned i, count;
17. ## Thread: Best way to learn Git

by Salem
Replies
1
Views
142

### Install it - Git for Windows...

Install it - Git for Windows

Familiarise yourself with various workflow patterns
- 5 Git Workflows & Branching Strategy to deliver better code
- Git Workflow | Atlassian Git Tutorial

Use it.
18. ## Thread: Breaking out of a function properly?

by Salem
Replies
7
Views
336

### Yes, that's pretty much how it would work.

Yes, that's pretty much how it would work.
19. ## Thread: Breaking out of a function properly?

by Salem
Replies
7
Views
336

### You have something like this void foo_FC80 (...

You have something like this

void foo_FC80 ( ) {
if ( ... ) {
} else {
// JMP \$EE0A in the stack frame of baz()
}
}
void bar() {
20. ## Thread: More thoughts on random floats

by Salem
Replies
15
Views
527

### Beware that the LSB of rand() might not be all...

Beware that the LSB of rand() might not be all that it seems.
Question 13.18
21. ## Thread: Printing long double gives zero

by Salem
Replies
7
Views
256

### cant print correctly a long double in C - Stack...

cant print correctly a long double in C - Stack Overflow
The problem stems from MinGW using the Microsoft runtime library (the code that implements printf).
This is all well and good until you get...
22. ## Thread: C - Server/Client Example

by Salem
Replies
4
Views
428

### So run the code in the debugger and find out more...

So run the code in the debugger and find out more information.

1. Compile with debug information
gcc -g -o client client.c

gdb ./client

3. At the next prompt type...
23. ## Thread: Remove the extension of a file passed as a parameter (argv[1])

by Salem
Replies
2
Views
429

### You can use strrchr...

You can use strrchr to find the last '.' in a string.
24. ## Thread: How to view program version number ?

by Salem
Replies
2
Views
522

### In your makefile (or some pre-build step), do ...

In your makefile (or some pre-build step), do

echo 'const char *version="'\$(git describe --abbrev = 4 --always --tags)'";"' > version_info.c

Then compile and link with that file, with an...
25. ## Thread: Anyone familiar with 68xx assembly AND C?

by Salem
Replies
27
Views
1,079

### > If the conditional falls through (in other...

> If the conditional falls through (in other words, the 'else' case), there are instructions to discard the subroutine address from the stack