Double decremented by 1 when cast as int?

I don't know if this is a bug or not or if I'm making some idiot mistake.

sensorValue = analogRead(sensorPin);
sensorPinValue = round(sensorValue/128);
if (sensorValue > 0){
lv = pow(2,sensorPinValue + 1) - 1;
ltLevel = int(lv);
lights(ltLevel);

lights() just hits an 8bit ic wired to some led's but i noticed some strangeness when passing a double to shiftOut.

Be aware that sensorPinValue can be zero even when sensorValue is > 0.

Also, pow() is very slow and unnecessary when raising 2 to an integer power.

try

lv = (1 << (sensorValue/128)) - 1;

It would be useful to see the declarations of the variables in your code, and a description of what you want to achieve.

I'm making some idiot mistake.
but i noticed some strangeness when passing a double to shiftOut.

To use your words, yes, you are making some idiot mistake. The shiftOut function expects an integer value. Why are you passing it a double?

When posting code, at least post enough of it to let us see what the problem is.

In the snippet you posted, the types of sensorValue, sensorPinValue, lv, and ltLevel are not defined.

The analogRead function returns an integer. Then, you divide that value by 128 (an integer value), resulting in an integer value. Then, you pass that integer to round(). That was a waste of a function call.

As drhex pointed out, there are far faster, more efficient bit manipulation techniques that using pow(). Look at bitSet, bitWrite, bitClear, and bitRead.

Paying attention to types will pay off in the long run, too.