shift register on ATtiny85 programming logic

So I just started my first project using an Arduino, which was to program an ATtiny85. So far so good. Programming went smoothly, though I had (and still have) a few problems with the shift register. Anyhow, this is my current circut:

my code is pretty simple:

#include <PISO74HC165.h>

PISO74HC165 reg(2,1,0,1);

int powerRelay = 4;
int led = 3;
int data = 0;

void setup() {
  pinMode(led, OUTPUT);
  pinMode(powerRelay, OUTPUT);
  digitalWrite(powerRelay, HIGH);

  data = reg.getData();
  for (int i=data;i>=0;i--)
    digitalWrite(led, HIGH);
    digitalWrite(led, LOW);
  digitalWrite(powerRelay, LOW);

void loop() {

and the library:

#define PULSE_WIDTH_USEC   5

#include "Arduino.h"
#include "PISO74HC165.h"

int _PIN_PL; 
int _PIN_Q7; 
int _PIN_CP;
int _dataWidth;

PISO74HC165::PISO74HC165(int ploadPin, int clockPin, int dataPin, int registerCount)
	_PIN_PL = ploadPin;  
	_PIN_Q7 = dataPin; 
	_PIN_CP = clockPin; 
	_dataWidth = registerCount * 8;

    pinMode(_PIN_PL, OUTPUT);
    pinMode(_PIN_CP, OUTPUT);
    pinMode(_PIN_Q7, INPUT);

int PISO74HC165::getData()
    byte bitVal;
    int bytesVal = 0;
	digitalWrite(_PIN_PL, HIGH);
	digitalWrite(_PIN_CP, LOW);

	digitalWrite(_PIN_PL, LOW);
    digitalWrite(_PIN_PL, HIGH);
    for(int i = 0; i < _dataWidth -1; i++)
		digitalWrite(_PIN_CP, HIGH);
		digitalWrite(_PIN_CP, LOW);
		bitVal = digitalRead(_PIN_Q7);
		if (bitVal)
			bytesVal += pow(2, i);


basically all the program does is read the Dip switch and output the count of the on switches in LED flashes.

(I should point out that both the circuit and the code is set to ignore the D0 pin on the register, since for some unknown reason when it is HIGH the out stays on HIGH regardless of everything else)

Now the issue that I am having is that for some reason bit 1 delivers one blink, bit 2 delivers 2 blinks, so far so good, but everything after bit 2 delivers the correct amount minus 1 blink. So bit 3 delivers 3 blinks (should be 4) bit 4 delivers 7 blinks (should be 8) and so on…

Can anyone recognize the problem?

bytesVal += pow(2, i);

the pow() function converts the params to float and has a rounding error
add/use ipow() to solve this

long ipow(int x, int e)
  long p = 1;
  for (int i=0; i<e; i++) p *= x;
  return p;

I also just found out that the pow is the problem, Thanks, I was going to create my own, but since you allready did it for me ^_^