I have no idea why I can't get this to work, if anybody can help i would appreciate it.
#!/bin/bash
x=`cat counter.txt | wc -l`
y= '$x / 7'
printf "%d People have visited this page" $y
:confused: (2 Replies)
Hi,
I am new to unix and using linux 7.2. I would like to create a script that would make it easyer for me to run my java programms. At the moment I have to type java myJavaprogram
I am trying to write a script that will allow me to type something like this "myscript myJavaprogram" or maybe... (4 Replies)
I am begining to learn bourne shell and as a practice I have written a script which when given the purchase price and percentage of discount calculates the savings.
I somehow cannot figure out why my script fails to do arthimatic calculation on real numbers.
Could anyone look at the script... (5 Replies)
Discussion started by: Tirmazi
5 Replies
4. Post Here to Contact Site Administrators and Moderators
page
unix com/answers-frequently-asked-questions/13785-yesterdays-date-date-arithmetic.html
Date Arithmetic with the Shell
has link of
www samag com/documents/s=8284/sam0307b/0307b.htm
which is no longer.
Is this the correct place to post this?:confused:
and I got message... (1 Reply)
Hello everybody,
I decided to take a Unix Introduction class and have never had experience with programming. Everything was fine until recently when the Prof. started shell scripting and he wants us to make a small script to add unlimited numbers from arguments and from standard input.
I... (1 Reply)
Hello everybody,
I decided to take a Unix Introduction class and have never had experience with programming. Everything was fine until recently when the Prof. started shell scripting and he wants us to make a small script to add unlimited numbers from arguments and from standard input.
I... (8 Replies)
I need help on arithmetic
root@server # hour=`date | awk {'print $4'} | cut -d: -f 1`; echo $hour
04
Now I subtract this result by 1 or 01 I get "3" as the answer. I need "03" as the answer, ie last two significant numbers should be there.
root@server # hour=`date | awk {'print $4'} | cut... (3 Replies)
Hi,
I need a help with arithmetic calculations in my script. I have two variables: a=17; b=1712
I want to perform ($a/$b)*100 with two decimals in the result.
I tried with following:
res=$((100*a/b))
res=`echo "scale=2; $a / $b" | bc`
But I am not getting the decimal values.... (4 Replies)
i am having a varialbe a , which is input to my file
i want to multiply this input with value .43, and assign it to variable b.
i tried it as below:
#!/bin/sh
a=$1
b=`expr $1\*0.43`
echo b=$b
error : expr: non-integer argument
Please tell me , how to do this.
Thanks (10 Replies)
Discussion started by: rishifrnds
10 Replies
LEARN ABOUT PHP
gmp_div_q
GMP_DIV_Q(3) 1 GMP_DIV_Q(3)gmp_div_q - Divide numbersSYNOPSIS
GMP gmp_div_q (GMP $a, GMP $b, [int $round = GMP_ROUND_ZERO])
DESCRIPTION
Divides $a by $b and returns the integer result.
PARAMETERS
o $a
- The number being divided. Either a GMP number resource in PHP 5.5 and earlier, a GMP object in PHP 5.6 and later, or a numeric
string provided that it is possible to convert the latter to a number.
o $b
- The number that $a is being divided by. Either a GMP number resource in PHP 5.5 and earlier, a GMP object in PHP 5.6 and later,
or a numeric string provided that it is possible to convert the latter to a number.
o $round
- The result rounding is defined by the $round, which can have the following values:
o GMP_ROUND_ZERO: The result is truncated towards 0.
o GMP_ROUND_PLUSINF: The result is rounded towards +infinity.
o GMP_ROUND_MINUSINF: The result is rounded towards -infinity.
Either a GMP number resource in PHP 5.5 and earlier, a GMP object in PHP 5.6 and later, or a numeric string provided that it is pos-
sible to convert the latter to a number.
RETURN VALUES
A GMP number resource in PHP 5.5 and earlier, or a GMP object in PHP 5.6 and later.
EXAMPLES
Example #1
gmp_div_q(3) example
<?php
$div1 = gmp_div_q("100", "5");
echo gmp_strval($div1) . "
";
$div2 = gmp_div_q("1", "3");
echo gmp_strval($div2) . "
";
$div3 = gmp_div_q("1", "3", GMP_ROUND_PLUSINF);
echo gmp_strval($div3) . "
";
$div4 = gmp_div_q("-1", "4", GMP_ROUND_PLUSINF);
echo gmp_strval($div4) . "
";
$div5 = gmp_div_q("-1", "4", GMP_ROUND_MINUSINF);
echo gmp_strval($div5) . "
";
?>
The above example will output:
20
0
1
0
-1
NOTES
Note
This function can also be called as gmp_div(3).
SEE ALSO gmp_div_r(3), gmp_div_qr(3).
PHP Documentation Group GMP_DIV_Q(3)