06-03-2002
sqrt is in the math library. Add -lm to your cc command and ld will find it.
6 More Discussions You Might Find Interesting
1. Programming
I was writing a simple program in linux, which includes sqrt function of c.
I included the math.h. But when I use gcc to compile it, it gave an error message:
/home/murat/tmp/ccOv9upo.o(.text+0x4b): In function `main':
: undefined reference to `sqrt'
collect2: ld returned 1 exit status
I... (2 Replies)
Discussion started by: murataht
2 Replies
2. Shell Programming and Scripting
HI,
I have a file which i catenate and using the fields in the file, I would like to get sqrt of it. I tried to man the function but it normally would need an echo as well as bc.
What I am intending to find out is catenate a file where let say
cat a.txt| awk ' {
t= h*($3+$2);
t=... (7 Replies)
Discussion started by: ahjiefreak
7 Replies
3. Shell Programming and Scripting
hi friends
can any body tell me how can i find sqrt of a any given number without using expr in bash shell
while i am doing i got some errors please take a look
and code is here
x=$((( ( sqrt($1) ) | bc )))
echo $x
$ sh quadratic-eqn-roots.sh 9
quadratic-eqn-roots.sh: line 12: ( (... (6 Replies)
Discussion started by: srinivas2828
6 Replies
4. Programming
This so basic that it should work.... Any ideas would be appreciared. Using a number directly in the sqrt allows it to compile.
primrose > cat a.c
#include <stdio.h>
#include <math.h>
int main(void)
{
double abcd=9;
printf("%f\n",sqrt(abcd));
}
primrose > gcc a.c
Undefined first... (2 Replies)
Discussion started by: plastichead
2 Replies
5. UNIX for Dummies Questions & Answers
Hi,
i have a the following script:
#!/bin/bash
a=3
b=9
let "c= b*a"
let "d=sqrt $c "
echo $d
But when i execute the code, it gives me the an error saying:
line 5: let: d=sqrt 27 : syntax error in expression (error token is "27 ")
Can any body tell me what I'm doing wrong? (5 Replies)
Discussion started by: limadario
5 Replies
6. Shell Programming and Scripting
Hi all...
This is just a fun project to see if it is possible to get a square root of a positive integer from 1 to 9200000 to 6 decimal places on a 64 bit architecture machine.
It is coded around dash and the results show the values from 0 to 10000.
Complex numbers can easily be catered for by... (3 Replies)
Discussion started by: wisecracker
3 Replies
sqrt(3M) sqrt(3M)
NAME
sqrt(), sqrtf(), sqrtl(), sqrtw(), sqrtq() - square root functions
SYNOPSIS
HP Integrity Server Only
DESCRIPTION
returns the non-negative square root of x.
is a version of it takes a argument and returns a result.
Integrity Server Only
is a version of it takes a argument and returns a result.
is an version of it takes an argument and returns an result.
is equivalent to on HP-UX systems.
USAGE
To use these functions compile either with the default option or with the and the options.
To use (for Integrity servers) or compile also with the option.
To use any of these functions, make sure your program includes and link in the math library by specifying on the compiler or linker command
line.
For more information, see the at the following site:
RETURN VALUE
If x is +INFINITY, returns +INFINITY.
If x is NaN, returns NaN.
If x is less than zero, returns NaN and raises the invalid floating-point exception.
raises the inexact exception whenever a rounded result does not equal the mathematical result.
ERRORS
If x is less than zero, sets to [EDOM].
Integrity Server Only
HP-UX functions on Integrity servers do not set by default. For setting, compile with the option and the (default) option.
SEE ALSO
cbrt(3M), exp(3M), log(3M), pow(3M), math(5).
STANDARDS CONFORMANCE
: SVID3, XPG4.2, ANSI C, ISO/IEC C99 (including Annex F, ``IEC 60559 floating-point arithmetic'')
: ISO/IEC C99 (including Annex F, ``IEC 60559 floating-point arithmetic'')
sqrt(3M)