Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

bash programming - displaying (real) numbers

Posted on 2003-03-06
2
Medium Priority
?
204 Views
Last Modified: 2011-09-20
Hello!
I'm having problems with bash programming - when i try to do something like:
a=3
b=5
echo div: $(($a/$b))
I get 'div: 0'.
How can i display decimals?
|bc -l? how?

TNX
0
Comment
Question by:jurij
2 Comments
 
LVL 29

Accepted Solution

by:
MikeOM_DBA earned 150 total points
ID: 8081886
Try this:

$a=3
$b=7
$ echo "$a $b"|awk '{printf "Div: %5.5f\n",$1/$2;}'
Div: 0.42857
0
 
LVL 2

Expert Comment

by:jimbb
ID: 8086367
a=3
b=5
decimal_places=3

echo "scale=$decimal_places; $a/$b" | bc
0

Featured Post

Get quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month15 days, 23 hours left to enroll

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question