PDA

View Full Version : Square root

Chompy
11-28-2006, 11:47 PM
Simple question, is there square root (built-in) in gscript?

Yen
11-29-2006, 12:02 AM
x^.5 is the same thing.

Chompy
11-30-2006, 02:38 PM
x^.5 is the same thing.

Thanks, was hoping for a built-in one tho, but that will work :)

contiga
11-30-2006, 03:29 PM
Thanks, was hoping for a built-in one tho, but that will work :)

You could create a public function squareRoot( v) return v ^ 0.5;
xP

_Z3phyr_
11-30-2006, 03:31 PM
I thought that sqrt(val) worked as well? Or am I soo 5 years ago or something

Chompy
11-30-2006, 04:09 PM
You could create a public function squareRoot( v) return v ^ 0.5;
xP

:p maybe I will :)

I thought that sqrt(val) worked as well? Or am I soo 5 years ago or something

Didn't work, but I know that sqrt(float) works in some other script languages like C I think

ApothiX
11-30-2006, 04:14 PM
Didn't work, but I know that sqrt(float) works in some other script languages like C I think
C isn't a 'script language', and it only works because there is a library that implemented it.

#include <math.h>
double sqrt(double);
or something like that.

Chompy
11-30-2006, 04:25 PM
C isn't a 'script language', and it only works because there is a library that implemented it.

#include <math.h>
double sqrt(double);
or something like that.

oh, didn't know that :p Well, thanks guys, I'll now start working on something I needed square root for :)

jake13jake
12-01-2006, 12:15 AM
Massokre's Interesting Fact of the Day:
The ENIAC, a computer that was used in the design of the hydrogen bomb, had a divider/square-rooter built into it's hardware. It could perform 40 divides per second or 3 square roots per second.

Chompy
12-01-2006, 12:19 AM
Massokre's Interesting Fact of the Day:
The ENIAC, a computer that was used in the design of the hydrogen bomb, had a divider/square-rooter built into it's hardware. It could perform 40 divides per second or 3 square roots per second.
:O I didn't know that for sure :p

Nice, now Stefan can find this computer and connect it too graal? :D
Did you make the bomb? :)

12-01-2006, 12:34 AM
Square root is done by x^0.5, which is actually internally converted into a sqrt() C call for best speed

Chompy
12-01-2006, 12:38 AM
Square root is done by x^0.5, which is actually internally converted into a sqrt() C call for best speed

:O so x^0.5 equal to sqrt(x)? nice

jake13jake
12-01-2006, 01:38 AM
*wants his xor operator back* :-(

I'd even be willing to write the program that would convert everyone's nw files and scripts from

a^b to pow(a,b),
a^=b to a=pow(a,b)
and,
a xor b to a^b

Chompy
12-01-2006, 04:36 PM
*wants his xor operator back* :-(

I'd even be willing to write the program that would convert everyone's nw files and scripts from

a^b to pow(a,b),
a^=b to a=pow(a,b)
and,
a xor b to a^b

How I use Xor, is this >_>

function onCreated() {
var1 = "foo";
var2 = "bar";
echo(var1 xor var2 ? 1 : 0); // would return true
}
/*
True = Not alike
False = Alike
*/

ApothiX
12-02-2006, 03:11 AM
How I use Xor, is this >_>

function onCreated() {
var1 = "foo";
var2 = "bar";
echo(var1 xor var2 ? 1 : 0); // would return true
}
/*
True = Not alike
False = Alike
*/
X_x.. Why are you using xor on strings? That's not how it works :x

Tolnaftate2004
12-02-2006, 03:44 AM
How I use Xor, is this >_>

function onCreated() {
var1 = "foo";
var2 = "bar";
echo(var1 xor var2 ? 1 : 0); // would return true
}
/*
True = Not alike
False = Alike
*/

X_x.. Why are you using xor on strings? That's not how it works :x

Might as well be doing be doing "f" xor "b" considering I believe binary operators compare only one binary value (that is, the first binary value per argument)... Not that that piece of code is of any use to anyone (see Okie's post). "f" xor "b" is char(6), whatever that is. char(6) has an ASCII of 6 which is not 0, thus is true...

jake13jake
12-02-2006, 05:45 PM
Might as well be doing be doing "f" xor "b" considering I believe binary operators compare only one binary value (that is, the first binary value per argument)... Not that that piece of code is of any use to anyone (see Okie's post). "f" xor "b" is char(6), whatever that is. char(6) has an ASCII of 6 which is not 0, thus is true...

well, xor works logically, too. I would imagine that that would return false since both strings exist.

Chompy
12-02-2006, 09:30 PM
X_x.. Why are you using xor on strings? That's not how it works :x

Some guy told me to try out xor on strings :p
I have tried it on binary's, but I didn't quite understand it all :)

jake13jake
12-06-2006, 12:55 AM
Some guy told me to try out xor on strings :p
I have tried it on binary's, but I didn't quite understand it all :)

xor is both a binary operator and a bitwise operator!

boolean xor boolean : one or the other but not both
int xor int : see my bitwise operators tutorial