Hello everyone!
I have written a small code to test multiplying floats and longs and I am loosing the decimals. The solution to this calculation should be 8388607.161. I am thinking that this might have something to do with the size of the multiplication, since a float can't have this many decimals and integers? If this was to be the problem what solution could it have? Here is the code that I am using with my Arduino nano:
void setup() {
Serial.begin(9600);
}
void loop() {
unsigned long refFrequency = 20000000.0;
unsigned long quartzCount = 4194304.0;
unsigned long refCount = 10000001.0;
float quartzFrequency;
quartzFrequency = (float)refFrequency / (float)refCount;
quartzFrequency = quartzFrequency * (float)quartzCount;
Serial.print("Crystal frequency value: ");
Serial.println(quartzFrequency, 3);
delay(2000);
}