# Search:

Type: Posts; User: flp1969

Page 1 of 20 1

by flp1969
Replies
37
Views
764

Here's how:
16365
2. ## Thread: Should i use for loop on this? sorry im a beginner

by flp1969
Replies
12
Views
390

### Ahhhh... of course: 16363 I just don't know if...

Ahhhh... of course:
16363
I just don't know if double precision is sufficient to hold factorials of "big" numbers (like INT_MAX-2).

Testing here: 171 will cause overflow! 1755! overflows for...
3. ## Thread: Should i use for loop on this? sorry im a beginner

by flp1969
Replies
12
Views
390

### You do notice that your function is not well...

You do notice that your function is not well behaved for some values of x, don't you?
16361
And it's worse: The denominator isn't continuous for a lot of values (if considering x integer, it is...
4. ## Thread: Playing with random numbers

by flp1969
Replies
11
Views
272

### rand() is a pseudo random number generator. It...

rand() is a pseudo random number generator. It isn't really random, just appears to be. It depends on the initial value seeded to the algorithm. If this value is 12, rand() will always give you the...
5. ## Thread: Very weird issue with double to int conversion inside the loop

by flp1969
Replies
10
Views
478

### If the code is too complex for you to fix for...

If the code is too complex for you to fix for Windows (I don't do Windows in 14 years), then forget it... The explanation in post #9 should be sufficient.

And, yet... you forget, in both codes, to...
6. ## Thread: Create a string in binary from a decimal number

by flp1969
Replies
10
Views
395

### In essence it is the same thing. I've only notice...

In essence it is the same thing. I've only notice that any comparison results in 0 or 1 (not other values)... The if:

bin = n & 0x80; // isolate bit 7.
if ( bin == 1)
s[i] = '1';
else
...
7. ## Thread: Create a string in binary from a decimal number

by flp1969
Replies
10
Views
395

### Another thing: All numeric representations in a...

Another thing: All numeric representations in a computer are binary. When you do

int x = 10;
This "decimal" 10 is encoded in binary and put in memory (or register) as a binary value. So, you can...
8. ## Thread: single for loop --- two conditions??

by flp1969
Replies
3
Views
259

### General rule: for is only a clever way to write...

General rule: for is only a clever way to write while loops. With your example:

for (int i = 0, j = n - 1; i < j; i++, j--)
doSomething();
Is the same as:

/* block, because i and j are...
9. ## Thread: Very weird issue with double to int conversion inside the loop

by flp1969
Replies
10
Views
478

### As hamster_nz said, there is a problem of...

As hamster_nz said, there is a problem of rounding when using floating point, specially with pow(), since the power is calculated as:
16359
The natural logarithm is approximated, and the...
10. ## Thread: Very weird issue with double to int conversion inside the loop

by flp1969
Replies
10
Views
478

### Neither do I... It is a valid point, since MinGW...

Neither do I... It is a valid point, since MinGW uses MSVCRT??.dll and maybe pow() is implemented there.
11. ## Thread: Very weird issue with double to int conversion inside the loop

by flp1969
Replies
10
Views
478

### This is also my suspicion... Since x^y (^ as...

This is also my suspicion... Since x^y (^ as potency) is calculated as e^(y*ln(x)) and, maybe, MinGW implementation of pow() can be a little bit wrong (there's a final approximation that need to be...
12. ## Thread: Very weird issue with double to int conversion inside the loop

by flp1969
Replies
10
Views
478

### I have my suspicions: Please compile and run this...

I have my suspicions: Please compile and run this program and post what is printed (on Windows) -- don't forget to link the libm library.

/* test.c */

#include <stdio.h>
#include <math.h>
...
13. ## Thread: Who can check my code?

by flp1969
Replies
3
Views
575

### john.c and stahta01 have a point (sorry didn't...

john.c and stahta01 have a point (sorry didn't resist the pun).

You are dealing with triangle SIDES, not vertices. And choosing 3 random values between -10 and 10:

rand()/(float)RAND_MAX ->...

by flp1969
Replies
5
Views
473

I can
15. ## Thread: Unable to accept input

by flp1969
Replies
6
Views
413

### Shoudn't be %f instead of %d?

Shoudn't be %f instead of %d?
16. ## Thread: Selection Sort in C

by flp1969
Replies
5
Views
415

### Selection sort... walk through the first element...

Selection sort... walk through the first element to the last but one (i). Inside that loop, walk to the second element to the last (j). Compare element at position i to the element at position j. If...
17. ## Thread: Anyone familiar with linux file APIs?

by flp1969
Replies
15
Views
694

### /proc/mounts or /proc/self/mounts

/proc/mounts or /proc/self/mounts
18. ## Thread: Win-bash use

by flp1969
Replies
5
Views
762

### Another thing: This is not valid: \$ x = 1 x:...

Another thing: This is not valid:

\$ x = 1

Assignments must not have spaces:

\$ x=1
\$ echo \$x
1
19. ## Thread: Round A Negative Number

by flp1969
Replies
11
Views
576

### Then it is a "practical" rounding, as in high...

Then it is a "practical" rounding, as in high school?
-0.001 is closer to 0.00 or -0.01?
20. ## Thread: Round A Negative Number

by flp1969
Replies
11
Views
576

### You didn't read, did you? Floating point isn't...

You didn't read, did you? Floating point isn't decimal!
21. ## Thread: Round A Negative Number

by flp1969
Replies
11
Views
576

### You do realize floating point is not "decimal"...

You do realize floating point is not "decimal" and not accurate enough to represent 0.001, don't you?

Floating point is a fractional representation using 3 unsigned integer values: S, F and E,...
22. ## Thread: DD to DMS

by flp1969
Replies
5
Views
582

### float has 24 bits of precision, not 25... But you...

float has 24 bits of precision, not 25... But you can use double (53 bits). In an Intel or ARM processor there's no difference in performance (only double has "double" the size, in comparison with...
23. ## Thread: Find if number x is less than y without comparison operator.

by flp1969
Replies
6
Views
734

### Ahhh... and this works very well: int...

Ahhh... and this works very well:

int lessThan( int a, int b )
{ return (a - b) >> ( sizeof(int) * CHAR_BIT - 1 ); }
Right shift with signed integers are "dependent of implementation",...
24. ## Thread: Find if number x is less than y without comparison operator.

by flp1969
Replies
6
Views
734

### Well... no '

Well... no '<' operator here (hehe)...

// Intel/AMD:
int lessThan(int a, int b)
{
int r = 0;

__asm__ __volatile__ (
"cmpl %2,%1\n\t"
"sets %b0"
25. ## Thread: strtok: line split || cannot unhinge previous split

by flp1969
Replies
8
Views
649

### Hummmm.... interesting. Thanks.

Hummmm.... interesting. Thanks.
Results 1 to 25 of 500
Page 1 of 20 1