Rounding Script Help

I need some help with my rouding script. I have started pretty much from scratch and have no idea if its correct or even close but I have been trying and have gotten to this point. i keep getting syntax errors and im not sure what is wrong. Here is what I got

[code]
let value=$1;
while [ magn=1;"$value">\(magn10\); magn=10 ]
do
let digit=( $value/magn )%10
if [ $digit >= 5 ]
then
$value+=( "10"-$digit )$magn
else
$value-=( $digit
$magn )
fi
done
echo $value

[code/]

its supposed to take ./rounders 1447
and output 2000