x * 1000L - what does the L do

Hi,

1st post.

I have been working through some Arduio code and I have what I hope is a basic question.

In the code below that works perfectly 'duration' is multiplied by 1000L.

Why the L at the end?
What does it mean.

void playTone(int tone, int duration) {
  for (long i = 0; i < duration *1000L; i += tone *2) {
    digitalWrite(speakerPin, HIGH);
    delayMicroseconds(tone);
    digitalWrite(speakerPin, LOW);
    delayMicroseconds(tone);
  }
}

I'm tryingt o understand when I just multiply my 1000 and when I multiply by 1000L.

I tried removing the L from the code but it failed, so obviously it is important.

Any info much appreciated.

Albert.

Why the L at the end? What does it mean.

The L declares that the value is a long. Without the L, the value of duration * 1000 would be interpreted as an int, which can hold a maximum value of 32,767, limiting duration to a maximum of 32.

With the L, duration * 1000L is treated as a long, which can hold a much larger value.

PaulS

Thanks for that.
This helped me find the reference page on arduino.cc

Again, thanks for this.