The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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



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

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Rounding off to the next whole number damansingh Shell Programming and Scripting 2 07-17-2008 06:18 AM
Very ANNOYING Problem - Please Help shadow0001 Shell Programming and Scripting 7 03-12-2008 06:28 PM
Rounding problem shash UNIX for Dummies Questions & Answers 2 01-18-2007 05:33 AM
Rounding off using BC. noodlesoup Shell Programming and Scripting 3 09-11-2006 12:38 AM
a very annoying problem Stormpie UNIX for Dummies Questions & Answers 2 04-24-2002 12:29 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-26-2008
Indalecio Indalecio is offline
Registered User
  
 

Join Date: Sep 2006
Location: Sweden
Posts: 59
Annoying rounding issue in awk

Hello
I am getting this very annoying issue in awk:

Code:
awk '{a=12825;b=a*1.25; print b}' test
16031.2
Thing is the multiplication result is wrong... Result should be 16031.25.
I think the issue only happens on bigger numbers.

What can I do to get passed this?
Thanks by advance
  #2 (permalink)  
Old 08-26-2008
tayyabq8's Avatar
tayyabq8 tayyabq8 is offline Forum Advisor  
Moderator
  
 

Join Date: Nov 2004
Location: Bahrain
Posts: 578
Code:
awk '{a=12825;b=a*1.25; printf "%5.2f\n", b}' test
  #3 (permalink)  
Old 08-26-2008
Indalecio Indalecio is offline
Registered User
  
 

Join Date: Sep 2006
Location: Sweden
Posts: 59
Edit: nevermind, I need to test more
  #4 (permalink)  
Old 08-26-2008
Indalecio Indalecio is offline
Registered User
  
 

Join Date: Sep 2006
Location: Sweden
Posts: 59
Alright

This doesn't work:

Code:
awk '{ a="12825";  
          b="16031.25"; 
          c=a*1.25; 
          if (b != c) printf "%5.2f\t%5.2f\n",b,c  
      }' test
Edit: and replacing the strings by numbers does work ???
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On



All times are GMT -4. The time now is 06:04 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0