Not able to save incoming data from GPS

I have this code

#include <TinyGPS++.h>
#include <SoftwareSerial.h>

static const int RXPin = 11, TXPin = 10;
static const uint32_t GPSBaud = 9600;
TinyGPSPlus gps;
SoftwareSerial ss(RXPin, TXPin);
int latitude;
int longitude; 

void setup()
{
  Serial.begin(9600);
  ss.begin(GPSBaud);
}

void loop()
{
  while (ss.available() > 0)
    if (gps.encode(ss.read()))
      displayInfo();
  if (millis() > 5000 && gps.charsProcessed() < 10)
  {
    Serial.println(F("No GPS detected: check wiring."));
    while(true);
  }
}

void displayInfo()
{
  if (gps.location.isValid())
  { 
    Serial.print("\n");
    Serial.print(gps.location.lat(), 7);
    
    Serial.print("\t");
    Serial.print(gps.location.lng(), 7);
  }
  else
  {
    Serial.print(F("INVALID"));
  }
}

It does exactly what I want it to. It prints GPS coordinates in the serial monitor. But I want to use the GPS coordinates in a more advanced code which means I need to save the latitude and longitude.

If i replace this part of the code:

  if (gps.location.isValid())
  { 
    Serial.print("\n");
    Serial.print(gps.location.lat(), 7);
    
    Serial.print("\t");
    Serial.print(gps.location.lng(), 7);

with

  if (gps.location.isValid())
  { 
    Serial.print("\n");
    latitude = (gps.location.lat(), 7);
    Serial.print(latitude);
    
    Serial.print("\t");
    longitude = (gps.location.lng(), 7);
    Serial.print(longitude);

then the serial print prints only 7’s.

Somehow, someway, gps.location.lat() and gps.location.lng() can be called by direct serialprint functions, but they can’t be saved, then called. Any idea why?

    latitude = (gps.location.lat(), 7);
    Serial.print(latitude);

is not the same as

 Serial.print(gps.location.lat(), 7);

Looks like you need

    latitude = gps.location.lat();
    Serial.print(latitude,7);

Correct... It actually also wants me to use float instead of int.

tbanari:
Correct... It actually also wants me to use float instead of int.

If you expected the latitude and longitude to be an int, what would the units be ?

tbanari:
Correct... It actually also wants me to use float instead of int.

What does "it" refer to?

@OP

Can you please, post a screenshot of your Serial Monitor that shows the values of the received latitude and longitude.