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 > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
convert Regular decimals to Packed decimals mgirinath Shell Programming and Scripting 2 09-20-2008 10:27 AM
Bourne and decimals?? kdyzsa Shell Programming and Scripting 1 05-06-2008 11:54 PM
handle decimals subin_bala Shell Programming and Scripting 1 04-21-2008 09:03 AM
Req on how to convert hex numbers to decimals hare UNIX for Advanced & Expert Users 3 03-21-2008 11:04 AM
Multiplying Floats/Decimals rleebife Shell Programming and Scripting 10 08-02-2007 06:22 AM

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 04-03-2009
3junior 3junior is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 9
How to multiple decimals in linux

How to multiple decimals in Linux?
When I do it like this i get an error message

echo "$((1 * 1.1))"
-bash: 1 * 1.1: syntax error in expression (error token is ".1")
  #2 (permalink)  
Old 04-03-2009
Corona688 Corona688 is offline
Registered User
  
 

Join Date: Aug 2005
Location: Saskatchewan
Posts: 1,944
The bash shell does not support floating point numbers, but you can use the bc tool like this:
Code:
$echo '2 * 3.5' | bc
7.0
$
  #3 (permalink)  
Old 04-03-2009
3junior 3junior is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 9
bc doesn't like variables another way
  #4 (permalink)  
Old 04-04-2009
danmero danmero is online now Forum Advisor  
  
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 1,431
Wink

Code:
a=2
b=3.5
echo "$a * $b" | bc
7.0
  #5 (permalink)  
Old 04-04-2009
vidyadhar85's Avatar
vidyadhar85 vidyadhar85 is offline Forum Staff  
Moderator(The Tutor)
  
 

Join Date: Jun 2008
Location: INDIA
Posts: 1,400
you can do like this also
Code:
awk 'BEGIN{print .9*.9}'
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:16 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