Many thanks for your answers, I tried both and the one that it's close to what I need is bartus11's code. However, I forgot to say that I have a range of values from 0 to 100 000. In fact, this code worked well for most of my values (and also more than 100 000), but I have problems in the range between 99.5 and 999.4. For example, if I run the code with:
then I get 99, which is very good.
However, from 99.5 to 999.4, I get 000. In this case, for instance, I expect to have with the number 459.3244, just 450.
In the case this code coulnd't be modified to cover the whole range (from 0 to 100 000), how could the script be modified to cover the range from 99.5 to 999.4?
I'm very grateful for your excellent support, many thanks again,
Heyas
Trying to calculate the total size of a file by reading its bitrate.
Code snippet:
fs_expected() { #
# Returns the expected filesize in bytes
#
pr_str() {
ff=$(cat $TMP.info)
d="${ff#*bitrate: }"
echo "${d%%,*}" | $AWK '{print $1}' | head -n 1
}
t_BYTERATE=$((... (9 Replies)
I have a number, which I want to convert into the nearest floating number upto two places after the decimal point.
E.g.
1.2346 will become 1.23
but
1.2356 will become 1.24 .
Similarly
0.009 will be 0.01
and
0.001 will be 0.00 or 0.0 (not 0, wnat to keep the decimal... (1 Reply)
Hi all of you,
Would be great if you help me with how to round up to whole number from my input values like
2.99996,2.17890,3.00002,-2.3456,-2.7890
o/p should be like 3,2,3,-2,-3
thnks in adv!!!!
regards (3 Replies)
Hi,
I am currently using tcsh
I am trying to round a decimal number to the ten-thousandths place
For instance:
1.23456 is rounded up towards 1.2346
I am not looking for truncation, but for rounding. Anyone know how to do this with awk or expr?
Thanks (2 Replies)
I need some help with my rouding script. I have started pretty much from scratch and have no idea if its correct or even close but I have been trying and have gotten to this point. i keep getting syntax errors and im not sure what is wrong. Here is what I got
let value=$1;
while
do
let... (4 Replies)
I need some help with my rouding script. I have started pretty much from scratch and have no idea if its correct or even close but I have been trying and have gotten to this point. i keep getting syntax errors and im not sure what is wrong. Here is what I got
let value=$1;
while
do
let... (0 Replies)
Hi Guys,
I am generating a statistical report , below is the snippet of the code :
Now, $nSlices stands for the time duration,meaning,the statistics will be displayed for that particular time duration. Trouble is, for certain values of $totalTime (which is the end time - start time ), i... (9 Replies)
Hello,
I searched a lot on this Forum.
Please help me with the below problem.
I want to divide two numbers and the result should be the next nearest whole number.
E.G. Dividing 10.8/5 ideally gives 2.16. But the result should be 3 i.e. rounded off to the next whole number.
Any help will... (2 Replies)
Hello again.
I'm trying to use BC to calculate some numbers in a shell script.
I want to have the numbers rounded off to 1 decimal place.
for example:
initsize=1566720
zipsize=4733
I'm trying to get the ratio between them. the equation is:
(($initsize-$zipsize)/$initsize)*100
so... (3 Replies)