# Search:

Type: Posts; User: flp1969

Page 1 of 20 1

1. ## Thread: Find if number x is less than y without comparison operator.

by flp1969
Replies
6
Views
154

### 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",...
2. ## Thread: Find if number x is less than y without comparison operator.

by flp1969
Replies
6
Views
154

### 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"
3. ## Thread: strtok: line split || cannot unhinge previous split

by flp1969
Replies
8
Views
173

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

Hummmm.... interesting. Thanks.
4. ## Thread: strtok: line split || cannot unhinge previous split

by flp1969
Replies
8
Views
173

### Just a warning... When you do: line = NULL,...

Just a warning... When you do:

line = NULL, len = 0;
while ( getline( &line, &len, fp ) != -1 )
{
...
}
You are asking to getline allocate enough space to hold the first line, but if the...
5. ## Thread: Get Exponent of Float

by flp1969
Replies
16
Views
317

### There is a "portable" way. Using frexpf(): ...

There is a "portable" way. Using frexpf():

float m;
int e;

m = frexpf( value, &e );
printf( "Value=%f -> m=%f, e=%d\n", value, m, e );
frexpf() returns values between 0<=m<1, and e is the...
6. ## Thread: Launching programmes in Win32 & Linux/Unix/Posix

by flp1969
Replies
4
Views
203

### Windows has CreateProcess() function on Win32 API.

Windows has CreateProcess() function on Win32 API.
7. ## Thread: Mixing mode 0 and 1 for SPI programming

by flp1969
Replies
7
Views
318

### Share your code... I have no experience with...

Share your code... I have no experience with PIC32, but already skim both datasheets. Glad to help if I can...

by flp1969
Replies
4
Views
620

GLFW
9. ## Thread: Mixing mode 0 and 1 for SPI programming

by flp1969
Replies
7
Views
318

### Nope, it isn't unusual. And I don't see the...

Nope, it isn't unusual. And I don't see the problem. The implementation is trivial:

1- setup a 16 bit result to 0;
2- Set SDI to 1 and pulse the CNV signal (0 to 1 and back to 0, Tcnv ns [1->0...
10. ## Thread: Mixing mode 0 and 1 for SPI programming

by flp1969
Replies
7
Views
318

### Without the actual interface between PIC and AD...

Without the actual interface between PIC and AD isn't possible to tell you anywhing. Show the circuit and your attempt with code...

Did you tried the CS-Mode?

16335
11. ## Thread: i did not understood to the question. But i did i don't know is this correct or not

by flp1969
Replies
2
Views
262

### A small program to test this: #include...

A small program to test this:

#include <stdio.h>
#include <math.h>

float fact ( unsigned int x )
{
float n = 1.0;

while ( x > 1 )

by flp1969
Replies
5
Views
373

### Or, using the wrapper functions and worrying...

Or, using the wrapper functions and worrying about endianess:

#include <unistd.h>
#include <arpa/inet.h>

int n = 1;

// Write all bytes of n in BIG ENDIAN format.
n = htonl( n );
13. ## Thread: More thoughts on random floats

by flp1969
Replies
15
Views
589

### Using RDRAND: // test.c - code for x86-64...

Using RDRAND:

// test.c - code for x86-64 (gcc).
#include <stdio.h>
#include <stdlib.h>
#include <x86intrin.h>

static int check_rdrand ( void );
static double rand_ ( double, double );
14. ## Thread: More thoughts on random floats

by flp1969
Replies
15
Views
589

### You asked for a "platform neutral" method......

You asked for a "platform neutral" method... rand() returns an uniform distributed random number in the range 0..RAND_MAX, usually through a LCG algorithm. In a 32 bit processor this is, again,...
15. ## Thread: More thoughts on random floats

by flp1969
Replies
15
Views
589

### #define swapd(a,b) ( double t_; t_ = (a); (a) =...

#define swapd(a,b) ( double t_; t_ = (a); (a) = (b); (b) = t_; }

double rand_range( double min, double max )
{
double r;

if ( min > max )
swapd( min, max );

r = rand() /...
16. ## Thread: Printing long double gives zero

by flp1969
Replies
7
Views
272

### Ok. At this magnitude a long double has 1 ULP =...

Ok. At this magnitude a long double has 1 ULP = 0.5. It means the imprecision is +/- 0.25. As for a double, 1 ULP = 1024 giving an imprecision of +/- 512. To illustrate, 5579207423999930400.0 cannot...
17. ## Thread: Printing long double gives zero

by flp1969
Replies
7
Views
272

### What do you mean "large values"? double supports...

What do you mean "large values"? double supports values between +/-1.78769*10³⁰⁸ (large enough for me).
Using long double is always a overkill (large object representation in memory and no support...
18. ## Thread: C - Server/Client Example

by flp1969
Replies
4
Views
455

### And: 1- gethostbyname() is an old and obsolete...

And:

1- gethostbyname() is an old and obsolete function. Use getaddrinfo();
3- Don't use...

by flp1969
Replies
6
Views
307

### author='Your name here' for file in *.c; do ...

for file in *.c; do
sed -i "s/<File Name>/\$file/;s/<Author>/\$author/;s/<Date>/\$(date)/" \$file
done
20. ## Thread: pointer struggles ???

by flp1969
Replies
7
Views
685

### ridderunnersjw, think of pointers as types that...

ridderunnersjw, think of pointers as types that hold an address and addresses are unsigned integers (linke indices of an array). In C there are a difference in declaring an object and using it. If...
21. ## Thread: How to generate a random number in the interval of -1 and 1?

by flp1969
Replies
17
Views
1,088

### Ahhh... of course, since we change the scale from...

Ahhh... of course, since we change the scale from 2⁰ to 2⁻¹! Nice catch.
22. ## Thread: error in function

by flp1969
Replies
3
Views
503

### Looks like you are trying to mimic the asprintf()...

Looks like you are trying to mimic the asprintf() GNU's function:

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>

int asprintf ( char **p, char *fmt, ... )
{
int size;
23. ## Thread: How to tell gcc to compile for Windows ?

by flp1969
Replies
6
Views
504

### There are some predefined symbols for Windows:...

There are some predefined symbols for Windows: _WIN32 (this exists on mingw and VC++), __WINNT__
24. ## Thread: How to generate a random number in the interval of -1 and 1?

by flp1969
Replies
17
Views
1,088

### That's interesting, Malcom! I completely forgot...

That's interesting, Malcom! I completely forgot about linear interpolation!

#include <stdlib.h>
#include <float.h>

#define lerp(min_, max_, norm) \
( (min_)*(1.0 - (norm)) + (max_)*(norm)...
25. ## Thread: How to generate a random number in the interval of -1 and 1?

by flp1969
Replies
17
Views
1,088

### In time: You are correct about the duplicates....

In time: You are correct about the duplicates. There are none. My mistake.
Results 1 to 25 of 500
Page 1 of 20 1