static const double LONDON_LAT = 51.508131, LONDON_LON = -0.128002;

What does this mean?


The above link contains the full example program of that line.

This line is from tinygps++ library for extracting the coordinates and displaying in a table format. I'm using arduino uno, GSM module and GPS module to extract the coordinates and transmit it as message. Can anyone explain what dies this constant value mean and why do we use this?

  • 5
    Unlike in movies, I hardly think London will ever move.
    – Kwasmich
    Commented Sep 21, 2020 at 8:21
  • 1
    We declare those because the program in which they are declared wants to use that information in some way. Without knowing what the program is we can't say why it might want to know that information. Maybe it wants to work out how far from London you are.
    – Majenko
    Commented Sep 21, 2020 at 8:45
  • 1
    This link contains the full program. Sorry to attach the link, since the program to too lengthy. Commented Sep 21, 2020 at 8:50
  • 1
    I'm currently working on a project, where the my location coordinates is to be sended as message using GSM module. The GPS coordinates are extracted using gps module. These are connected to arduino uno board. Tinygps and tinygps++ library is being used for this project. This program is an full example program which is default in tinygps++ library Commented Sep 21, 2020 at 8:53
  • 1
    I was actually asking for a particular line, which was mentioned 1st. static const double LONDON_LAT = 51.508131, LONDON_LON = -0.128002; Commented Sep 21, 2020 at 12:15

2 Answers 2


Static variables are allocated storage only once in a program lifetime The const keyword specifies that a variable's value is constant and tells the compiler to prevent the programmer from modifying it and you can't change const variable's value and i guess you know double is a data type that can save floating point numbers that line declare two variables with names LONDON_LAT and LONDON_LON and both of them are in one line and because london's latitiude and longtitude doesn't change the const keyword is used

also i guess because those variables are constants you can use #define visit https://www.arduino.cc/reference/en/language/structure/further-syntax/define/


It's a good idea to declare variables the strictest possible way. So if you don't intend to change the value of LONDON_LAT at runtime, declare it as const.

This allows the compiler to alert you if your code tries to modify it, and it often allows the compiler to optimize the code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.