Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Square root (https://forums.graalonline.com/forums/showthread.php?t=70460)

Chompy 11-28-2006 11:47 PM

Square root
 
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

Quote:

Originally Posted by Yen (Post 1248279)
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

Quote:

Originally Posted by Chompy (Post 1248739)
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

Quote:

Originally Posted by contiga (Post 1248747)
You could create a public function squareRoot( v) return v ^ 0.5;
xP

:p maybe I will :)

Quote:

Originally Posted by _Z3phyr_ (Post 1248748)
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

Quote:

Originally Posted by Chompy (Post 1248756)
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.

PHP Code:

#include <math.h>
double sqrt(double); 

or something like that.

Chompy 11-30-2006 04:25 PM

Quote:

Originally Posted by ApothiX (Post 1248758)
C isn't a 'script language', and it only works because there is a library that implemented it.

PHP Code:

#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

Quote:

Originally Posted by jake13jake (Post 1248892)
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? :)

Admins 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

Quote:

Originally Posted by Stefan (Post 1248911)
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

Quote:

Originally Posted by jake13jake (Post 1248946)
*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 >_>

PHP Code:

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


ApothiX 12-02-2006 03:11 AM

Quote:

Originally Posted by Chompy (Post 1249091)
How I use Xor, is this >_>

PHP Code:

function onCreated() {
 
var1 "foo";
 
var2 "bar";
 echo(
var1 xor var2 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

Quote:

Originally Posted by Chompy (Post 1249091)
How I use Xor, is this >_>

PHP Code:

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


Quote:

Originally Posted by ApothiX (Post 1249220)
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

Quote:

Originally Posted by Tolnaftate2004 (Post 1249230)
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

Quote:

Originally Posted by ApothiX (Post 1249220)
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

Quote:

Originally Posted by Chompy (Post 1249412)
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


All times are GMT +2. The time now is 12:05 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.