Rob Landley wrote: > Implementing something by hand isn't _always_ a good alternative, sure. That > would be the "thinking about the problem" part. In this instance, avoiding > overflow is trivial. (If 1<<-1 didn't wrap around, it wouldn't even need the > if statement.) I don't think this affects your script but it's worth noting that both bash and ksh use arithmetic rather than logical shift for the >> operator. Now arithmetic shift is not useful on 2's compliment machines, and moreover it's compiler dependent as to whether arithmetic or logical shift is done for >>. Therefore to increase usefulness and decrease ambiguity, shells really should only shift unsigned variables internally. I know the opengroup spec says to use signed ints, but I think that is intended to disambiguate input and output, rather than defining internal operations. This is correct I think since the POSIX spec says you can even use floating point internally if you like. I asked the bash maintainer who said he would need clarification from the austin group (CC'd) before changing anything. cheers, Pádraig. -- To unsubscribe from this list: send the line "unsubscribe linux-embedded" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html