The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com




Thread: adding zero's
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 07-21-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
  
 

Join Date: Dec 2007
Location: Home of 17-time world champion Boston Celtics
Posts: 1,311
Wink printf reformats output, or can do a bc function


Code:
> x1=1234.20
> echo $x1
1234.20
> echo $(printf "%.4f" "$x1")
1234.2000

something else to think about


Code:
> x2=1234.2000
> x3=$(echo "$x1"-"$x2" | bc)
> echo $x3
0

Perhaps one of these approaches will help you.