Timer interrupt runs at half speed

Hello, I'm not new to arduino, been using it since 2011 and this is a first. So the following code should turn the LED on pin 13 on for 1 second and turn it off for another second. What happens is it turns it on for 2 seconds and turns ir off for another 2 seconds, I have even tried it on two arduinos, a genuine uno R2 and a clone nano with optiboot, same result on both. Thanks in advance!

unsigned long long x = 0;
bool ledstate = 0;

void setup() {
  pinMode(13, OUTPUT);

  TCCR0A = 0;
  TCCR0B = (1 << CS00); //prescaler 1/1
  TIMSK0 = (1 << OCIE0B);
  OCR0B = 100; //100 //160000 hz
}

void loop() {
  if(x>160000){
  ledstate = !ledstate;
  x = 0;
  }
  digitalWrite(13,ledstate);
}

ISR(TIMER0_COMPB_vect) {
  x++;
}

You are in normal mode, and the timer continues to run up to 255 and then resets and counts again from 0. You get your compare match at 100 every 255 counts.

To achieve your one second blink you want to be in CTC to OCR0A with OCR0A set at 99 (for 100 counts starting at 0).

To toggle the led, you can use either a compare match interrupt on either OCR0A or OCR0B = 99 or a timer overflow interrupt (TOIE0).

Either that or
OCR0B += 100;
on your ISR

Oh, thanks for pointing that out! Please take another look if that is a perfect solution or not?

unsigned long long x = 0;
bool ledstate = 0;

void setup() {
  pinMode(13, OUTPUT);

  TCCR0A = (1 << WGM01);
  TCCR0B = (1 << CS00); //prescaler 1/1
  TIMSK0 = (1 << OCIE0A);
  OCR0A = 100; //100 //160000 hz
}

void loop() {
  if(x>160000){
  ledstate = !ledstate;
  x = 0;
  }
  digitalWrite(13,ledstate);
}

ISR(TIMER0_COMPA_vect) {
  x++;
}