09-13-2004
bc calculate problem
Hi ,
this is the first time i use bc to calculate and i would have decimal result , i use the following :
toto=400;scale=1 echo $toto / 1000|bc
scale to adjust the numbers after the command would have in this case 0.4 as result and i wonder why i have always 0 as result.
Somebody can help ?
thanks
Christian
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi all
I have 3 three files like:
file1:
1|100
2|200
3|300
4|400
5|500
file2:
1|200
2|200
3|600
4|800
file3:
1|300
2|100 (5 Replies)
Discussion started by: koti_rama
5 Replies
2. Shell Programming and Scripting
I have 2 variables in my shell scripts in which i am using awk and calculating 2 files and getting 2 different variable called in_total and out_total. I want to subtract one variable from another so plz tell me how i can do that.
Example is:
cat in_file | awk -F: '{
in_total += $1 * 86400... (3 Replies)
Discussion started by: krishna_sicsr
3 Replies
3. Shell Programming and Scripting
Is there any awk command to calculate P Value ?(Probability)
Is it possib;e to calculate P va;ue for this data for ex?
7.891284
8.148193
7.749575
7.958188
7.887702
7.714877
8.141548
7.51845
8.27736
7.929853
7.92456
8.249126
7.989113
8.012573
8.351206 (2 Replies)
Discussion started by: stateperl
2 Replies
4. Shell Programming and Scripting
Hello,
I'm trying to create a shell script (#!/bin/sh) which should tell me the age of a file in minutes...
I have a process, which delivers me all 15 minutes a new file and I want to have a monitoring script, which sends me an email, if the present file is older than 20 minutes.
To do... (10 Replies)
Discussion started by: worm
10 Replies
5. Shell Programming and Scripting
Hi,
I have a file with more than 2,000 rows like this:
05/26/2011,1200,1500
I would like to create a awk shell script that calculate the price average of the second and third field each 5,10 and 20 rows or ask me for the values, starting at first row.
Finally compare the average value... (1 Reply)
Discussion started by: csierra
1 Replies
6. Shell Programming and Scripting
Long list of input file:
AGDRE1 0.1005449050
AGDRE1 2.1005443435
AGDRE1 1.2005449050
AGDRE1 5.1005487870
AASFV3 50.456304789
AASFV3 2.3659706549
AASFV3 6.3489807860
AASFV3 3.0089890148
RTRTRS 5.6546403546
.
.
Desired output file:
AGDRE1 8.5021829410
AASFV3 62.180245240... (2 Replies)
Discussion started by: perl_beginner
2 Replies
7. UNIX for Dummies Questions & Answers
Hi.
For an homework, I have to simulate some part of the PS function. By reading the doc I've been able to find most of it but I don't how I can get the %cpu for each PID.
I've read on Internet that I have to do:
(utime(t)-utim(t-1))/(cputime(t)-cputime(t-1))
where cputime is the sum of... (2 Replies)
Discussion started by: elnabo
2 Replies
8. UNIX for Dummies Questions & Answers
i have file input
abcedef|wert|13|03|10|04|23|A1|13|05|01|09|31
fsdasdf|ferg|12|04|25|21|21|A1|13|02|26|20|31
dfsfsad|gerg|12|04|25|21|21|A1|13|02|25|25|31
i expect the output
abcedef|wert|13|03|10|04|23|A1|13|05|01|09|31|9.516666667... (5 Replies)
Discussion started by: radius
5 Replies
9. Shell Programming and Scripting
Experts,
file1 : Want to find the difference of $3 field from next line's 3rd field,
The difference to be calculated from next lines 3rd field, to current lines lines 3rd field.
file1 :
Jun24_2013.06242013 3301244928 3133059904 167370640 95%
Jun25_1124.06252013 3301244928... (4 Replies)
Discussion started by: rveri
4 Replies
10. Shell Programming and Scripting
Hi
is there a way to calculate the progress when using the tar -cvf a folder say of 300Gb (4 Replies)
Discussion started by: fretagi
4 Replies
BCPOWMOD(3) 1 BCPOWMOD(3)
bcpowmod - Raise an arbitrary precision number to another, reduced by a specified modulus
SYNOPSIS
string bcpowmod (string $left_operand, string $right_operand, string $modulus, [int $scale = int])
DESCRIPTION
Use the fast-exponentiation method to raise $left_operand to the power $right_operand with respect to the modulus $modulus.
PARAMETERS
o $left_operand
- The left operand, as a string.
o $right_operand
- The right operand, as a string.
o $modulus
- The modulus, as a string.
o $
scale -This optional parameter is used to set the number of digits after the decimal place in the result. You can also set the
global default scale for all functions by using bcscale(3).
RETURN VALUES
Returns the result as a string, or NULL if $modulus is 0.
NOTES
Note
Because this method uses the modulus operation, numbers which are not positive integers may give unexpected results.
EXAMPLES
The following two statements are functionally identical. The bcpowmod(3) version however, executes in less time and can accept larger
parameters.
<?php
$a = bcpowmod($x, $y, $mod);
$b = bcmod(bcpow($x, $y), $mod);
// $a and $b are equal to each other.
?>
SEE ALSO
bcpow(3), bcmod(3).
PHP Documentation Group BCPOWMOD(3)