STM32 NaN value for floating point operations on global variables
@MarkoBursic Thank you for pointing those out man. You know, actually i made so many changes in that tiny piece of code since yesterday that i started losing track of the idioticity :). Anyhow i have somehow managed to solve the problem. Bear with me for a while. using gdb i stepped through the code once again, checking each variable before and after every line of execution. leftvel was initially a nan(0x400000) when dt was zero since during the first iteration tickprev and ticknow were the same (0). Since leftvel and rightvel are local variables the nan values didnt stick through. And this nan value was getting multiplied to my global variables which are persistent. So i added this line :

if(isnan(leftvel) || isnan(rightvel))
    return;


Just before multiplying it with dx,dy and dw. Thank you for your suggestions @MarcoBursic @BenceKaulics