# Search:

Type: Posts; User: flp1969

Page 1 of 20 1

1. ## Thread: Round A Negative Number

by flp1969
Replies
11
Views
181

### 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?
2. ## Thread: Round A Negative Number

by flp1969
Replies
11
Views
181

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

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

by flp1969
Replies
11
Views
181

### 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,...
4. ## Thread: DD to DMS

by flp1969
Replies
5
Views
211

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

by flp1969
Replies
6
Views
219

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

by flp1969
Replies
6
Views
219

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

by flp1969
Replies
8
Views
254

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

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

by flp1969
Replies
8
Views
254

### 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...
9. ## Thread: Get Exponent of Float

by flp1969
Replies
16
Views
409

### 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...
10. ## Thread: Launching programmes in Win32 & Linux/Unix/Posix

by flp1969
Replies
4
Views
257

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

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

by flp1969
Replies
7
Views
370

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

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

by flp1969
Replies
7
Views
370

### 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...
14. ## Thread: Mixing mode 0 and 1 for SPI programming

by flp1969
Replies
7
Views
370

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

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

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

by flp1969
Replies
15
Views
647

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

by flp1969
Replies
15
Views
647

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

by flp1969
Replies
15
Views
647

### #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() /...
20. ## Thread: Printing long double gives zero

by flp1969
Replies
7
Views
308

### 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...
21. ## Thread: Printing long double gives zero

by flp1969
Replies
7
Views
308

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

by flp1969
Replies
4
Views
490

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

### 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
24. ## Thread: pointer struggles ???

by flp1969
Replies
7
Views
712

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

by flp1969
Replies
17
Views
1,153

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

Ahhh... of course, since we change the scale from 2⁰ to 2⁻¹! Nice catch.
Results 1 to 25 of 500
Page 1 of 20 1