Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
google site



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 !!

Reply
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Search this Thread
  #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: 101
Thanks: 4
Thanked 3 Times in 3 Posts
printf will do that.

man printf
  #3  
Old 03-14-2010
fpmurphy's Avatar
Moderator
 

Join Date: Dec 2003
Location: /dev/ph
Posts: 2,477
Thanks: 0
Thanked 37 Times in 36 Posts

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

Sponsored Links
Reply

Tags
awk, decimal, expr, rounding, tcsh

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


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
Round off decimal number to 2 decimal places? Vozx Shell Programming and Scripting 1 12-07-2005 09:53 PM



All times are GMT -4. The time now is 09:20 PM.