The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




Thread: BC Or Xcal
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 07-05-2005
bakunin bakunin is offline Forum Staff  
Bughunter Extraordinaire
  
 

Join Date: May 2005
Location: In the leftmost byte of /dev/kmem
Posts: 1,629
I vote for bc (or dc, or what else), because it is standard UNIX, unlike Xcal AND it is easy to script. Here is a rounding function in ksh, try scripting it with xcal instead of bc, here is just the core of it:

Code:
                                                 # calculate rounded value
nValue=$( print "scale=$iDigits; $( print "scale=$iDigit2; $nValue + $nAdd" |\
                                    bc \
                                  ) / 1" | \
          bc \
        )
bakunin