The UNIX and Linux Forums  

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



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Simple or maybe not.. marringi UNIX for Dummies Questions & Answers 1 04-01-2008 02:49 PM
Simple to you not simple to me pattern matchin help aleks001 Shell Programming and Scripting 0 07-22-2007 11:06 PM
Simple C question... Hopefully it's simple Xeed High Level Programming 6 12-15-2006 02:29 PM
Simple if GNMIKE Shell Programming and Scripting 2 12-04-2005 06:54 AM
Ok simple question for simple knowledge... Corrail UNIX for Dummies Questions & Answers 1 11-28-2005 01:03 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-01-2006
kekanap's Avatar
kekanap kekanap is offline
Registered User
  
 

Join Date: Sep 2003
Location: South Africa
Posts: 36
simple one

echo
echo

((zz=$ee+$ff+$aa))

echo $zz

<==Problem==>

ee= 12.5
ff = 20.6
aa = 10.5

The ouput of zz should be 43.6 BUT i am getting 42. So it means anything after the comma is not counted. Please help.
  #2 (permalink)  
Old 11-01-2006
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
Well, the shell does not support anything except integer arithmetic. In your case, all the numbers are getting rounded down, so your answer is 42. Try using bc for this:

Code:
echo "scale=1; $aa+$ee+$ff"|bc

  #3 (permalink)  
Old 11-01-2006
kekanap's Avatar
kekanap kekanap is offline
Registered User
  
 

Join Date: Sep 2003
Location: South Africa
Posts: 36
Thank you.

You suggestion worked.
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 11:15 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
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