This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

double trouble?

Hi all.

using uVision 4, keil compiler.

I'm trying to create a very simple function that takes an argument list, but it seems like when i use parameters of type double, it doesn't work right. I started fiddling around with the double datatype, and maybe i'm doing something wrong, but ...

// double trouble
double d = 1234.1234;
double* dp = &d;
double e = *dp;
// e has gibberish, d is fine

// float is ok
float f = 1234.1234;
float* fp = &d;
float g = *fp;
// g is fine, f is fine

// in fact ...
float f = 1234.1234;
float* fp = &d;
double g = *fp;
// g has gibberish, f is fine

// also ...
float f = 1234.1234;
double d = (double)f;
// d has gibberish(!)

// wha...
double d = 1234.1234;
double e = d;
// both d and e have gibberish.

// contrast to
float d = 1234.1234;
float e = d;
// both d and e are fine

// adding a pointer.. cures it?
double d = 1234.1234;
double* dp = &d;
double e = d;
// e has gibberish, d is fine.

// more pointers...
double d = 1234.1234;
double* dp = &d;
double e = d;
double* ep = &e;
// both d and e are fine.

can someone explain what's going on???

0