Parsing through the individual digits of a double


hi,

i've been working on project display gps location , i'm having trouble trying data in right format.

the data retrived via    int latitude =  gps.latitude;  in format: 4042.6142

i wanting divide prints lcd in format: +40° 42.6142'


i have tried:
code: [select]
string lat =gps.latitude; //// = 4042.6142
 
    serial.print("+"); serial.print(lat[0]); serial.print(lat[1]);serial.print("\"");
    for(int = 0; i< 7; i++){
      serial.print(lat[i+2]);
    }
    serial.print("'");
   

but error:  conversion 'double' non-scalar type 'string' requested


which gps library using?
you state "the data retrived via    int latitude =  gps.latitude;  in format: 4042.6142"
the type int cannot store number decimal places (i.e. "4042.6142") without truncating it. need use double try use character array instead , use strtok function parse string.
try stay away string class past posts have shown problems memory usage , bugs. if can ythe output type(s) of gps library using easier help.


Arduino Forum > Using Arduino > Programming Questions > Parsing through the individual digits of a double


arduino

Comments

Popular posts from this blog

VIDIOC_S_FMT error 16, Device or resource busy - Raspberry Pi Forums

using a laptop skeleton to build a pi laptop - Raspberry Pi Forums

Forum for Joomla? - Joomla! Forum - community, help and support