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
how to get rid of decimal point? cin2000 Shell Programming and Scripting 2 12-27-2005 12:26 PM
Round off decimal number to 2 decimal places? Vozx Shell Programming and Scripting 1 12-07-2005 10:53 PM
compare decimal numbers tmxps Shell Programming and Scripting 5 11-02-2005 06:46 PM
add numbers with decimal place in UNIX tads98 Shell Programming and Scripting 4 07-21-2005 05:17 AM
Packed Decimal gaddeg UNIX for Dummies Questions & Answers 1 06-21-2002 01:53 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-05-2005
Vozx Vozx is offline
Registered User
  
 

Join Date: Dec 2005
Posts: 12
Devision of Decimal Numbers?

How can i devide decimal numbers?

I am getting this kind of error:
line 18: 200.2/40.234: syntax error in expression (error token is ".2/40.234")

What can i do to work around this problem?

Thanks for any advice.
  #2 (permalink)  
Old 12-05-2005
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,717
Code:
kcsdev:/home/jmcnama>  var=`echo "scale=12;  .2  / 40.234"|bc`
kcsdev:/home/jmcnama> echo $var
kcsdev:/home/jmcnama> .004970920117
[/code]
  #3 (permalink)  
Old 12-05-2005
Vozx Vozx is offline
Registered User
  
 

Join Date: Dec 2005
Posts: 12
What does scale=12 mean?
  #4 (permalink)  
Old 12-06-2005
Vozx Vozx is offline
Registered User
  
 

Join Date: Dec 2005
Posts: 12
I encountered another problem whenever i devide a smaller number by a bigger number i.e. 4/9 instead of getting the answer as 0.4444444444 i just get 0

Why is that, and what can i do t oget the right answer?
  #5 (permalink)  
Old 12-07-2005
grasper grasper is offline
Registered User
  
 

Join Date: Sep 2005
Posts: 45
It's the same issue - the shell you're using can't deal with non-integers.

Use the same technique as jim has shown - pipe the expression through to the bc function.
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 05:25 AM.


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