I have the following code:
Code:
#include <msp430.h>#include "stdlib.h"
#include "stdio.h"
const char frq[8], br[8];
long f, b;
char *frqPtr, *brPtr;
int d;
float interim;
void main()
{
strcpy(frq, "16000000");
strcpy(br, "115200");
f = atol(frq);
b = atol(br);
interim = f/b/16;
d = (int)((interim - (int)interim) * 16);
}
After I run I get the following from the debugger:
interim float 8.0 0x002018
d int 0 0x00201C
f long 16000000 0x002014
b long 115200 0x002010
Can someone tell me how to get interim = 8.68055555556 and d = 10?
Problem solved: change f, b to float and cast