Hi All,
I've found what appear to be answers to this question but I just need a bit of help.
Struggling to implement a solution.
I am running a Teensy 3.2 and trying to convert a long integer into a double precision floating point.
My understanding is that the Teensy 3.2 uses software emulation for standard and double floats, and that by default, all floats are compiled as 32 bit.
If you want to declare a constant as a double float you have to put an L or I after it.
I am reading latitude from an RTK gps unit. It comes back as a long with the degrees then 7 decimal places.
For example 22.1234567 would come back as 221234567.
If I run the following code I get
as the result. It looks like the value is being rounded and losing precision.
I don't think the declaration of test
is the correct way to declare test as double precision.
Same with dividing by the constant which is declared as double precision
.
Any ideas on how to do this properly?
Paul.
I've found what appear to be answers to this question but I just need a bit of help.
Struggling to implement a solution.
I am running a Teensy 3.2 and trying to convert a long integer into a double precision floating point.
My understanding is that the Teensy 3.2 uses software emulation for standard and double floats, and that by default, all floats are compiled as 32 bit.
If you want to declare a constant as a double float you have to put an L or I after it.
I am reading latitude from an RTK gps unit. It comes back as a long with the degrees then 7 decimal places.
For example 22.1234567 would come back as 221234567.
If I run the following code I get
Code:
22.1234570
Code:
float test=0.0L;
long latitude = 221234567;
test = abs(latitude/10000000.0L);
Serial.printf( "%12.7lf",test );
I don't think the declaration of test
Code:
float test=0.0L;
Same with dividing by the constant which is declared as double precision
Code:
test = abs(latitude/10000000.0L);
Any ideas on how to do this properly?
Paul.