I am adding a series of 8196 64-bit unsigned integers, and I need the running-total to "roll-over" back to zero and continue counting from there... just as a "normal" programing language would do at the relevent INT_MAX ceiling.
As the test script shows, adding 1 to an boundary value (FF, FFFF, etc) just keeps on increasing the total. A feature, no doubt, but I'd like to limit it to 64-bits for this particular instance..
Is there some way to limit bc
in this?
unset f
for ((i=0; i<8; i++)); do
f=${f}FF; echo -ne "$((${#f}/2)) bytes + 1 "
echo 'ibase=16; obase=10; ('$f'+1)' |bc
done
echo "I want 8th+1 to = 0000000000000000"
# output
#
# 1 bytes + 1 100
# 2 bytes + 1 10000
# 3 bytes + 1 1000000
# 4 bytes + 1 100000000
# 5 bytes + 1 10000000000
# 6 bytes + 1 1000000000000
# 7 bytes + 1 100000000000000
# 8 bytes + 1 10000000000000000
# I want 8th+1 to = 0000000000000000