Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Search Forums:



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 03-13-2010
Registered User
 

Join Date: Mar 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Rounding a decimal

Hi,

I am currently using tcsh

I am trying to round a decimal number to the ten-thousandths place
For instance:
1.23456 is rounded up towards 1.2346

I am not looking for truncation, but for rounding. Anyone know how to do this with awk or expr?

Thanks
Sponsored Links
    #2  
Old 03-13-2010
Registered User
 

Join Date: Mar 2010
Location: la jolla, ca
Posts: 100
Thanks: 4
Thanked 3 Times in 3 Posts
printf will do that.

man printf
Sponsored Links
    #3  
Old 03-14-2010
fpmurphy's Avatar
who?
 

Join Date: Dec 2003
Location: /dev/ph
Posts: 4,045
Thanks: 35
Thanked 282 Times in 263 Posts

Code:
$ printf "%.4f\n" 1.23456
1.2346
$

Sponsored Links
Closed Thread

Tags
awk, decimal, expr, rounding, tcsh

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Rounding Script Help kingrj46 Shell Programming and Scripting 4 11-27-2009 10:28 AM
Rounding Script Help kingrj46 Linux 0 11-26-2009 02:33 PM
Rounding numbers down dcfargo UNIX for Dummies Questions & Answers 5 09-16-2008 07:14 PM
Rounding off using BC. noodlesoup Shell Programming and Scripting 3 09-11-2006 12:38 AM



All times are GMT -4. The time now is 03:24 AM.