LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-24-2012, 09:23 PM   #1
alavala53
LQ Newbie
 
Registered: Oct 2012
Location: Hyderabad
Posts: 10

Rep: Reputation: Disabled
not getting floating answer when divident is smaller than divider


not getting floating answer when divident is smaller than divider.getting 0 for all values
problem:
a=2 b=4
c=`echo $a / $b |bc`
echo $c

ans:
0

please help me in this issue
 
Old 10-24-2012, 09:29 PM   #2
Basher52
Member
 
Registered: Mar 2004
Location: .SE
Distribution: Arch
Posts: 396

Rep: Reputation: 22
Try this


Quote:
`echo "scale=2;2/3" |bc`
where scale=2 gives you 2 decimals

Quote:
a=2 b=4
c=`echo "scale=2;" $a / $b |bc`
echo $c

Last edited by Basher52; 10-24-2012 at 09:41 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Floating-Point Reentrancy Hazelrah Linux - Embedded & Single-board computer 0 08-02-2011 02:11 AM
Free disk space in '/' getting smaller and smaller. simjii SUSE / openSUSE 5 12-16-2005 11:24 AM
Floating point exception hemk76 Linux - Software 1 05-06-2005 11:49 PM
Does Solaris allows floating windows? montylee Solaris / OpenSolaris 6 11-30-2004 10:23 AM
Does *nix allows floating windows. montylee Other *NIX 1 11-29-2004 08:17 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration