Hey, thanks wildbill and EvolveElectronics for the replies.
Oh yes, 6 digits is too big for an int. That explains the weird number.
My ultimate goal is to simply display the number to my LCD display (1.8 Color TFT LCD display with MicroSD Card Breakout [ST7735R] : ID 358 : $19.95 : Adafruit Industries, Unique & fun DIY electronics and kits) in which the codes tft.drawString seems to accept character strings only. The conversion is just my work around since I only know how to convert int to character string such as this:
temperature = bmp.readTemperature()*10;
int tempwhole = bmp.readTemperature();
int tempdec = temperature % 10;
char tempall[10];
sprintf(tempall, "%.d.%.d C", tempwhole, tempdec);
tft.fillRect(10, 70, 100, 8, BLACK);
tft.drawString(10, 70, tempall, BLUE, 1); //prints 29.1 C
I know (not really sure :D) that this is not efficient but works for the meantime. But doing the same with the barometric pressure like:
pressure = bmp.readPressure();
float pressfwhole = pressure/1000;
int presswhole = (int)pressfwhole;
float pressfdec = pressure - presswhole*1000; //pressure % 1000 does not work
int pressdec = (int)pressfdec;
char pressall;
sprintf(pressall, "%.d.%.3d kPa", presswhole, pressdec); //gives error
tft.fillRect(10, 110, 100, 8, BLACK);
tft.drawString(10, 110, pressall, GREEN, 1);
gives an error: invalid conversion from 'char' to 'char*', to the line sprintf
however, commenting out char pressall; and down and adding serial print line:
Serial.print(presswhole);Serial.print(".");Serial.print(pressdec);Serial.println(" kPa");
gives out correct result as:
100.669 kPa
100.672 kPa
...etc...
Having said this, the conversion to long works fine but the problem still stands.
Any solution to either the float conversion or character string printing on the LCD?