>   1) I tried using Printf interface to print the floating point numbers
>  using %f and %lf arguments and by storing the number in float and
>  double datatypes and my using the number directly as in argument. In
>  all these cases the only thing printed is an "f". i had the impressing
>  that the C data types work fine in nesC but there seems to be some
>  problem in this case.
I have not tried to print floats in nesC, if this is anything like
Palm, it's merely a symptom of non-standard FP/lately integrated FP.
That is, if the "%f" shows up as "f" then the printf command -does not
recognize- that option.

>  2) I tried comparing two floating point numbers by:
>
>     2.1) Storing both number in float data type and then both in
>  double data type such as:
>
>            x=ran/256;         //where ran is an uint8_t storing a

***This will NEVER ASSIGN A FLOATING VALUE.***

In C, an expression is only as "dirty" as the dirties data-type.
(Okay, my term.)
In this case, that's an integer and an integer / integer -> integer.
You MUST cast or use a variable with floating point precision.
Try:
  x = ran;
  x /= 256;
Or
  x = (float)ran / 256;

>  because i'm printing 'ran' before this code, i know the comparison is
>  giving wrong results.
See above.

One way to "print" a floating point number might be:
printf("%d.%03d", fp, (fp - (int)fp) * 100);
YMMV: note the issues with negative numbers and rounding errors.

Paul
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to