Qhimm.com Forums

Miscellaneous Forums => Scripting and Reverse Engineering => Topic started by: Ant on 2001-11-20 13:09:00

Title: Performing square root calculations in c++?
Post by: Ant on 2001-11-20 13:09:00
How do you perform square root calculations in c++ ?

Thanks
Title: Performing square root calculations in c++?
Post by: The SaiNt on 2001-11-20 13:55:00
There is a header file you can include called math.h
Then you can use the function

sqrt(the number you want to squareroot);
Title: Performing square root calculations in c++?
Post by: Ant on 2001-11-20 15:11:00
Thanks SaiNT
Title: Performing square root calculations in c++?
Post by: Aaron on 2001-11-27 12:31:00
Can't you also do like

x^0.5
Title: Performing square root calculations in c++?
Post by: ficedula on 2001-11-27 14:24:00
Don't think so; C++ has this fixation with using symbols for as many things as possible ... I believe ^ is used to do binary XOR.
Title: Performing square root calculations in c++?
Post by: Qhimm on 2001-11-27 17:56:00
C++ has the pow(number, tothepowerof) function, I think. It's in the math.h library.
Title: Performing square root calculations in c++?
Post by: Ant on 2001-11-27 19:58:00
Aaron : I was doing that for a while wondering why it was spewing out some hideous result.(Too much VB on the brain - not a good thing :smile: )
Title: Performing square root calculations in c++?
Post by: Darkness on 2001-11-27 23:48:00
i dont completely understand the isdigit command of ctype.h..... I input 5 and get 4..... why? shouldn't i get 1?
Title: Performing square root calculations in c++?
Post by: The SaiNt on 2001-11-28 00:39:00
Quote

On 2001-11-27 19:48, Darkness wrote:
i dont completely understand the isdigit command of ctype.h..... I input 5 and get 4..... why? shouldn't i get 1?

How exactly did you use it?
Title: Performing square root calculations in c++?
Post by: Darkness on 2001-11-28 00:42:00
i was messing with it in my c++ class today......

something like this:

cin >> i;
x = isdigit(i);
if (x == 1)
{
       cout << "Character is a Digit";
}
else
{
       cout << "Character is not a Digit";
}
Title: Performing square root calculations in c++?
Post by: mirex on 2001-11-28 12:58:00
As the help says, isdigit returns nonzero if it is a number, else returns 0.

In c++ false = 0. true = anthing else.

fix that line to: if ( x )
or make it:
if (x == 0)
   cout << "Character is not a Digit";
else
   cout << "Character is a Digit";
Title: Performing square root calculations in c++?
Post by: Darkness on 2001-11-28 21:32:00
yup. i fixed it earlier today. thats the EXACT words of my textbook.