Hi all,

lately I was try to drop a small math operation as under

float latest;
uint16_t a=20,b=30;

latest = (a/b)*100

it was always giving me latest = 0, I have tried it with a bit of
variation:

latest =
((float)(totalTrafficLoad.packetsLost/totalTrafficLoad.packetsSend))*100;

but again 0

but when I tried something like:

latest = 100*totalTrafficLoad.packetsLost/totalTrafficLoad.packetsSend;

it starts giving me right results : 66.6

I am not sure what was the problem, can someone please explain it to me?

Wasif Masood
_______________________________________________
Tinyos-help mailing list
Tinyos-help@millennium.berkeley.edu
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to