Sponsored Content
Full Discussion: bc scale problem
Top Forums Shell Programming and Scripting bc scale problem Post 302556079 by cristalp on Friday 16th of September 2011 01:22:47 PM
Old 09-16-2011
bc scale problem

Dear Experts,

I want to use bc to do some multiplication and return me a value with number of decimal places defined by myself.

For example:
Code:
echo "scale=10; 1.65*7" | bc

returns me:
Code:
11.55

But what I really want is to have is a result with 10 digits after the point which should look like:
Code:
11.5500000000

But "scale" just doesn't work here. And, if I want to have result without decimal place, for 11.55, it should return me the result like:
Code:
12

Could I achieve these without the help of other command. I know I could pipe the result to awk or another bc (by division for which scale works), but I just interested in if a single bc with some special option can do it simply?

I would greatly appreciate to your kind help!

Last edited by cristalp; 09-16-2011 at 02:38 PM..
 

3 More Discussions You Might Find Interesting

1. Solaris

unable to allocate enough cells for gray scale

Hi, I tried to install a software (written in C) and run it on a sun machine. It is displaying the error: unable to allocate enough cells for gray scale. I closed all other apllications and set background to black to minimize usage of cells. But it is diaplaying the same error. Plz help... (1 Reply)
Discussion started by: raz
1 Replies

2. UNIX for Dummies Questions & Answers

Any company running large scale grid platform still

Hi buddy, I would like to know are there any company still running large scale grid platform like Parabon? Parabon is the only company running such kind of platform and purchasing CPU power. Is that right? Thanks, Colapig (0 Replies)
Discussion started by: colapig
0 Replies

3. Programming

Isosurface and a 2D figure with the same scale and origin using mayavi

I am using mayavi to plot an iso surface from a 3D array s using the following piece of code: src = mlab.pipeline.scalar_field(s) fig=mlab.pipeline.iso_surface(src, color=(1.0,0.0,0.0), contours=, opacity=0.3) mlab.pipeline.iso_surface(src, color=(0.0,1.0,1.0),contours=, opacity=0.3) Then... (0 Replies)
Discussion started by: jaldo0805
0 Replies
All times are GMT -4. The time now is 02:35 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy