Weird Number Appears on Serial.println()

Here is the code I uploaded to my Arduino UNO. Can someone please tell me why when I open my serial monitor, the number it reads is a column of 4294966296's instead of a column of 0's?

long previous = 0;
long interval = 1000;

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

void loop()
{
unsigned long current = millis();
if(current - previous >= interval)
{
previous = current;
Serial.println(current - previous - interval);
}
}

Hi MathematicsFanatic

First. Welcome to this forum.

Second. use your mouse to select # ← mean to place your code in between “code” and use “copy & paste” technique.

Third. your line : Serial.println(current - previous - interval); <— ???
What value you want to display ? It should be : Serial.println(myvalue, DEC); to display a decimal number. Maybe you want to display a result of the math inside the Serial.println() if that is the case : Serial.println((current-previous-interval),DEC);

Thank you for the welcome. I am in the process of teaching myself programming since I am an entering freshman and not in a Programming class yet. I have no clue of how electricity works so I am basically just playing and hopefully I will learn from there. I made the change to my program like you said. However, I was looking at an example program that was put on this forum and it said what I had should display a column of 0's on the display monitor. That is why I was confused that it gave such a huge number. Also when I made the changes it still displayed the large number. Please tell me what I am doing wrong.

long previous = 0;
long interval = 1000;

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

void loop()
{
  unsigned long current = millis();
  if(current - previous >= interval)
  {
    previous = current;
    Serial.println((current - previous - interval),DEC);
  }
}
    previous = current;
    Serial.println((current - previous - interval),DEC);

current and previous are equal so the println becomes…

    Serial.println((0UL - interval),DEC);

0xFFFFFFFF - 1000 + 1 = 0xFFFFFC18 = 4294966296. Is 4294966296 the output?

I suspect you meant to reset previous after printing the value…

    Serial.println((current - previous - interval),DEC);
    previous = current;

try

long previous = 0;
long interval = 1000;

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

void loop()
{
  unsigned long current = millis();
  if(current - previous >= interval)
  {
    previous = current;
    Serial.print(current,DEC);
    Serial.print(" - ");
    Serial.print(previous,DEC);
    Serial.print(" - ");
    Serial.println(interval,DEC);
  }
}