You are not using floating point variables.
Also printf uses a "%f" for flat format.
MS

Abdullah wrote:
> Hi there,
> 
> This code gives me wrong output. I don't know why!
> 
> event message_t* Receive.receive(message_t *msg, void *payload, uint8_t 
> len) {
>   
>   int32_t p = getRssi(msg);
>  
>   // t1 = p - c, where c = -67.03
>   int32_t t1 = p + 67.03;
>  
>   // t2 = t1 / a, where a = -15.73
>   int32_t t2 = t1 / -15.73;
>  
>   // d = 10^t2, where d is the distance in meters.
>   int32_t d = powf( 10.0, t2 );
>  
>   printf("%d dBm , %d m\n", p , d);
>     
>     //printf("Rssi Message received from node %d: %d dBm\n", call 
> Ieee154Packet.source(msg), getRssi(msg));
>     printfflush();
>     return msg;
>   }
> 
> 
> I cannot add/div float numbers, and I cannot print float numbers in 
> printf !!
> I'm using iris mote and tinyos, nc.
> 
> Cheers,
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Tinyos-help mailing list
> Tinyos-help@millennium.berkeley.edu
> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
_______________________________________________
Tinyos-help mailing list
Tinyos-help@millennium.berkeley.edu
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to