Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Tech Support (https://forums.graalonline.com/forums/forumdisplay.php?f=7)
-   -   foo^(n/m) (https://forums.graalonline.com/forums/showthread.php?t=61775)

Dach 10-16-2005 10:05 PM

foo^(n/m)
 
player.chat = 2^(1/3)@" "@(-2)^(1/3);

Will produce "1.259921049 0"
The first is correct, the second is clearly not. This seems to occur for any foo^(n/m) combination where n/m is not an integer as a whole.
Edit: It shouldn't do anything for when m is even, obviously. Since that does involve i (sqrt(-1)). Unless you want to return an array, but I don't really know when that would be usefull.

-1.259921049^3 is equivalent to 2, f.y.i.

Velox Cruentus 10-16-2005 11:04 PM

Umm... You are trying to square a negative number, sir... The value is undefined.


How about NOT going into magic numbers... Especially since 'i' is ALREADY taken. i is the most used variable, and I will not give it up for imaginary numbers! Now... Just don't square root negative numbers. Do this! abs(-2)^(1/2) @ "i" instead, alright?

EDIT:

2 ^ (1/3) == ~1.26
~1.26 != ~1.41 ( or 2^(1/2) )

Lance 10-16-2005 11:32 PM

Quote:

Originally Posted by Velox Cruentus
Umm... You are trying to square a negative number, sir... The value is undefined.


How about NOT going into magic numbers... Especially since 'i' is ALREADY taken. i is the most used variable, and I will not give it up for imaginary numbers! Now... Just don't square root negative numbers. Do this! abs(-2)^(1/2) @ "i" instead, alright?

EDIT:

2 ^ (1/3) == ~1.26
~1.26 != ~1.41 ( or 2^(1/2) )

Did you, uh, actually read the post?

Dach 10-17-2005 12:39 AM

Quote:

1.414213562
Don't ask me why that was there, I don't know.

Velox Cruentus 10-17-2005 12:49 AM

Quote:

Originally Posted by Lance
Did you, uh, actually read the post?

Hrm -- Misread that -- I was offthrown by his 2^(1/3) == 2^(1/2)... O,o; And my post would apply for 2^(1/2)... Bleh...

Yea... I guess it's a bug. Who would want the cube of a negative number anyways?

Fox1545 10-17-2005 02:08 AM

Quote:

Originally Posted by Velox Cruentus
Umm... You are trying to square a negative number, sir...

No, he is not. 1/3 is not 2.

Quote:

The value is undefined.
No, it is not. What the ****.

Quote:

How about NOT going into magic numbers...
He is not.
Magic numbers are a totally different bunch of concepts.

Quote:

Especially since 'i' is ALREADY taken. i is the most used variable, and I will not give it up for imaginary numbers!
No one is trying to take your precious undescriptive variable names. Also, use temp.i instead.

Quote:

Now... Just don't square root negative numbers.
Now... Just do not post anymore!

Quote:

Do this! abs(-2)
Yeah, sounds like a great use of the scripting engine's time.

Dach 10-17-2005 02:14 AM

Quote:

Originally Posted by Velox Cruentus
Yea... I guess it's a bug. Who would want the cube of a negative number anyways?

The only reason I came across it was from trying to get a more blocked ovaloid shape using sinus and cosinus to be honest, which is in itself an odd thing to do. Doesn't matter though, it's still something that should be looked into.

Velox Cruentus 10-17-2005 02:58 AM

Quote:

Originally Posted by Fox1545
No, he is not. 1/3 is not 2.


No, it is not. What the ****.


He is not.
Magic numbers are a totally different bunch of concepts.


No one is trying to take your precious undescriptive variable names. Also, use temp.i instead.


Now... Just do not post anymore!


Yeah, sounds like a great use of the scripting engine's time.


If you read my post later on, I thought he was talking about 2^(1/2), not 2^(1/3)... There is a difference (He made an error in what he 2^(1/3) was, and I recognized it as 2^(1/2). Thus, I thought he was talking about imageinary numbers, but that isn't the case because of the misconception.)

Admins 10-17-2005 04:06 AM

Well most math functions don't allow that, Graal is already accepting more than the basic C++ library functions.
It is true that e.g. -8 = -2 * -2 * -2, so -8^1/3 = -2.
But.
The exponent is specified as one number, not divider and divisor (not sure about the english names for those). While -8 ^1/3 is possible to calculate, -8 ^ 0.333333333 is not, since the precision of floating point numbers is limited and 0.333333333 is not exactly the same like 1/3.

Fox1545 10-17-2005 04:19 PM

Quote:

Originally Posted by Stefan
The exponent is specified as one number, not divider and divisor (not sure about the english names for those). While -8 ^1/3 is possible to calculate, -8 ^ 0.333333333 is not, since the precision of floating point numbers is limited and 0.333333333 is not exactly the same like 1/3.

Ruby allows -8 ** 0.333333333 and returns -1.99999999861371 ^^

protagonist 10-17-2005 06:37 PM

Quote:

Originally Posted by Fox1545
Ruby allows -8 ** 0.333333333 and returns -1.99999999861371 ^^

But 1/3 is irrational, not 0.333333333.

Fox1545 10-18-2005 01:22 AM

Quote:

Originally Posted by protagonist
But 1/3 is irrational, not 0.333333333.

Let me introduce you to φ.

φ is a nifty number. It is approximately 1.61803, but not exactly. You could try to express it as the ratio between two integral numbers, but you will inevitably fail, and not because you suck at numbers. 16:10 is a pretty good approximation, but not the exact thing, because φ is slightly more than that. 16:9 or 17:10 are not exactly better.

So, you can apply some fancy math on φ's definition which I will skip and you get φ = (1+sqrt(5))/2. This is so complicated because φ is not just any number like 4, 15.3 or 343209443214, but inherently irrational.

Now, compare φ to 1/3. As you might notice, most of what I said about φ does not apply to 1/3. 1/3 is exactly 1/3 and not some crazy fraction with square roots and other mathematical gadgets. You can easily say 1/3 using the two integral numbers 1 and 3. Even without fancy math. I think that makes 1/3 rational.

So please stop responding to my posts.

Admins 10-18-2005 02:01 AM

Quote:

Originally Posted by Fox1545
Ruby allows -8 ** 0.333333333 and returns -1.99999999861371 ^^

Ah really? Then I need to add support for it too :D Eventually it could check if 1/exponent is close to an even integer number.

protagonist 10-18-2005 05:50 AM

Quote:

Originally Posted by Fox1545
Let me introduce you to φ.

φ is a nifty number. It is approximately 1.61803, but not exactly. You could try to express it as the ratio between two integral numbers, but you will inevitably fail, and not because you suck at numbers. 16:10 is a pretty good approximation, but not the exact thing, because φ is slightly more than that. 16:9 or 17:10 are not exactly better.

So, you can apply some fancy math on φ's definition which I will skip and you get φ = (1+sqrt(5))/2. This is so complicated because φ is not just any number like 4, 15.3 or 343209443214, but inherently irrational.

Now, compare φ to 1/3. As you might notice, most of what I said about φ does not apply to 1/3. 1/3 is exactly 1/3 and not some crazy fraction with square roots and other mathematical gadgets. You can easily say 1/3 using the two integral numbers 1 and 3. Even without fancy math. I think that makes 1/3 rational.

So please stop responding to my posts.

I think I meant to say non-terminating; my error. However, it's impossible to for a non-terminating number to have an exact value, and it is erroneous to assign one.

In any case, 0.333333... is still not 1/3.

Dach 10-18-2005 08:20 PM

a^1/b when a is negative and b is odd, mulitply a by -1, do the arithmetic, then multiply the answer by -1

Everyone and their mother knows that fractions are represented by limited precision floating point values in computers. The only question is whether or not to actually support this, granted it really shouldn't be that big of a deal to add.


All times are GMT +2. The time now is 09:26 PM.

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