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

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

its supposed to take ./rounders 1447
and output 2000

I posted this in the OS sub forum also. NOOB mistake i know but hey its my first day. SOrry

Your script seems to have a considerable disregard for syntax. I suggest you start with some minimal segments of your code and just see if they work.

---------- Post updated at 02:17 ---------- Previous update was at 02:02 ----------

Alright, here you go. I turned it further into a bash/ksh kind of script:

value=$1
for (( magn=1;value>magn*10; magn*=10 ))
do
  (( digit=(value/magn)%10 ))
  if (( digit >= 5 ))
  then
    (( value+=(10-digit)*magn ))
  else
    (( value-=(digit*magn) ))
  fi
done
echo $value

It doesn't work right, but at least it runs :wink:

very cool. Thanks, I will play with it some more and try to get it to work. If i need more help I will post here again. Thanks so much, I was already getting frustrated.

variables cannot contain spaces, and neither should file names.

unix not windows...

actually most languages do not allow this, c/c++ java, to name a few.

Not sure I follow. I dont think i put any spaces in either. Is there something I missed?