Sponsored Content
Top Forums Shell Programming and Scripting Need help in using power function in Bash Post 302178638 by ahjiefreak on Wednesday 26th of March 2008 04:31:41 AM
Old 03-26-2008
It seems not working if i used them in associative array.
Code:
yup=5*(g-$2)+4*$2+4*$3;

  if(test !=0)
    count[$1]=24^(g-$2) +24^$2 +8^(h-$3) +8^$3;
 else
    count[$1]=2^yup;

where g and h are declared as variables (awk -v g="$g" -v h="$h" )

Please advise.Thanks.
 

9 More Discussions You Might Find Interesting

1. Programming

power function in C

Hi, I wrote a small program to find 2 to the power of 3, when I tried to execute the following error occured. How can I solve this problem? $ cat t1.c #include <math.h> #include<stdio.h> main() { int a=2; int b=3; int c; c = a ^ b; /* if i use ** instead of ^ also the same problem... (2 Replies)
Discussion started by: krishna
2 Replies

2. Shell Programming and Scripting

Need assistance with bash function

Hi all! I need a little help with an imbedded fuction I am trying to write. What I am trying to do is go to a series of hosts and get the contents of an XML file, storing some of the data, along with the name of the host it was gathered from. My intent is to store this in an array for later... (1 Reply)
Discussion started by: _jade_
1 Replies

3. Shell Programming and Scripting

bash search function

I want to have a function with a similar interface: search *.cpp asdf that will search recursively all directories for *.cpp file, containing line 'asdf' inside. I tried this: function search { find . -name "$1" | xargs grep -li $2; } But it doesn't work all the time. For example, if i run it... (3 Replies)
Discussion started by: doze
3 Replies

4. Shell Programming and Scripting

BASH function error

Hey everyone. I am currently testing my first function based BASH script. The ultimate goal is going to be moving logs from point A to point B (or if B is down, to point C). Part of this involves the following function: function testAlive{ ping -c 1 -q $1 } Now when I run ping -c... (1 Reply)
Discussion started by: msarro
1 Replies

5. Shell Programming and Scripting

Bash function

startvm() { startguest } Is there a way use one line to get this ? actually I want startvm=startguest (5 Replies)
Discussion started by: yanglei_fage
5 Replies

6. UNIX for Dummies Questions & Answers

Bash INKEY$ function...

This is probably common knowledge to the professionals but not so much for amateurs like myself. This is a code snippet for the equivalent of BASIC's... LET char$=INKEY$ As the timeout parameter cannot be less than 1 second then this is the only limitation... It is a single line... (5 Replies)
Discussion started by: wisecracker
5 Replies

7. Shell Programming and Scripting

Yes or No selection within bash function

I need to add a selection within the bash function below and am having some trouble doing so. phox2b() { printf "\n\n" printf "What is the id of the patient getting Phox2B analysis : "; read id printf "Is this an intronic variant? Y/N "; read match_choice case... (5 Replies)
Discussion started by: cmccabe
5 Replies

8. Shell Programming and Scripting

Bash function, for BSD

I am putting this thread to shell-threads, because it is about how to make a function work properly. I need a hint for declaring a function right, it has been more than a year I did not work that straight with bash. So my aim is to turn off the eth0 (as it would be in linux, and bge0 in bsd ),... (2 Replies)
Discussion started by: 1in10
2 Replies

9. Shell Programming and Scripting

Bash function problem

I am trying to figure out why I am having a "problem" with some functions in a bash script I am running. The reason for air quoting is that the functions are working, they are just not displaying anything to screen when called from another function. Here's an example: function Create_Input {... (6 Replies)
Discussion started by: dagamier
6 Replies
POW(3)									 1								    POW(3)

pow - Exponential expression

SYNOPSIS
number pow (number $base, number $exp) DESCRIPTION
Returns $base raised to the power of $exp. Note In PHP 5.6 onwards, you may prefer to use the ** operator. PARAMETERS
o $base - The base to use o $exp - The exponent RETURN VALUES
$base raised to the power of $exp. If both arguments are non-negative integers and the result can be represented as an integer, the result will be returned with integer type, otherwise it will be returned as a float. EXAMPLES
Example #1 Some examples of pow(3) <?php var_dump(pow(2, 8)); // int(256) echo pow(-1, 20); // 1 echo pow(0, 0); // 1 echo pow(-1, 5.5); // PHP >4.0.6 NAN echo pow(-1, 5.5); // PHP <=4.0.6 1.#IND ?> NOTES
Note This function will convert all input to a number, even non-scalar values, which could lead to weird results. SEE ALSO
exp(3), sqrt(3), bcpow(3), gmp_pow(3). PHP Documentation Group POW(3)
All times are GMT -4. The time now is 09:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy