Graal Forums  

Go Back   Graal Forums > Development Forums > Tech Support
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 10-16-2005, 10:05 PM
Dach Dach is offline
call me Chad, it's cooler
Dach's Avatar
Join Date: Aug 2002
Posts: 1,899
Dach is on a distinguished road
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.
__________________
Scripting Documents:Old Script Documentation-Movement Tutorial

Last edited by Dach; 10-17-2005 at 12:17 AM..
Reply With Quote
  #2  
Old 10-16-2005, 11:04 PM
Velox Cruentus Velox Cruentus is offline
Registered User
Velox Cruentus's Avatar
Join Date: Dec 2004
Location: Quebec, Canada
Posts: 465
Velox Cruentus is on a distinguished road
Send a message via ICQ to Velox Cruentus Send a message via AIM to 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) )
__________________
In a world of change... Who'll you believe?
Reply With Quote
  #3  
Old 10-16-2005, 11:32 PM
Lance Lance is offline
dark overlord
Lance's Avatar
Join Date: Sep 2003
Location: Space Jam Mountain
Posts: 5,072
Lance is on a distinguished road
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?
Reply With Quote
  #4  
Old 10-17-2005, 12:39 AM
Dach Dach is offline
call me Chad, it's cooler
Dach's Avatar
Join Date: Aug 2002
Posts: 1,899
Dach is on a distinguished road
Quote:
1.414213562
Don't ask me why that was there, I don't know.
__________________
Scripting Documents:Old Script Documentation-Movement Tutorial
Reply With Quote
  #5  
Old 10-17-2005, 12:49 AM
Velox Cruentus Velox Cruentus is offline
Registered User
Velox Cruentus's Avatar
Join Date: Dec 2004
Location: Quebec, Canada
Posts: 465
Velox Cruentus is on a distinguished road
Send a message via ICQ to Velox Cruentus Send a message via AIM to Velox Cruentus
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?
__________________
In a world of change... Who'll you believe?
Reply With Quote
  #6  
Old 10-17-2005, 02:08 AM
Fox1545 Fox1545 is offline
Registered User
Join Date: Jul 2004
Posts: 78
Fox1545 is on a distinguished road
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.
Reply With Quote
  #7  
Old 10-17-2005, 02:14 AM
Dach Dach is offline
call me Chad, it's cooler
Dach's Avatar
Join Date: Aug 2002
Posts: 1,899
Dach is on a distinguished road
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.
__________________
Scripting Documents:Old Script Documentation-Movement Tutorial
Reply With Quote
  #8  
Old 10-17-2005, 02:58 AM
Velox Cruentus Velox Cruentus is offline
Registered User
Velox Cruentus's Avatar
Join Date: Dec 2004
Location: Quebec, Canada
Posts: 465
Velox Cruentus is on a distinguished road
Send a message via ICQ to Velox Cruentus Send a message via AIM to Velox Cruentus
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.)
__________________
In a world of change... Who'll you believe?
Reply With Quote
  #9  
Old 10-17-2005, 04:06 AM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
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.
Reply With Quote
  #10  
Old 10-17-2005, 04:19 PM
Fox1545 Fox1545 is offline
Registered User
Join Date: Jul 2004
Posts: 78
Fox1545 is on a distinguished road
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
Reply With Quote
  #11  
Old 10-17-2005, 06:37 PM
protagonist protagonist is offline
Banned
protagonist's Avatar
Join Date: May 2003
Location: CAW
Posts: 5,586
protagonist is on a distinguished road
Send a message via AIM to protagonist Send a message via MSN to protagonist
Quote:
Originally Posted by Fox1545
Ruby allows -8 ** 0.333333333 and returns -1.99999999861371
But 1/3 is irrational, not 0.333333333.
Reply With Quote
  #12  
Old 10-18-2005, 01:22 AM
Fox1545 Fox1545 is offline
Registered User
Join Date: Jul 2004
Posts: 78
Fox1545 is on a distinguished road
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.
Reply With Quote
  #13  
Old 10-18-2005, 02:01 AM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
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 Eventually it could check if 1/exponent is close to an even integer number.
Reply With Quote
  #14  
Old 10-18-2005, 05:50 AM
protagonist protagonist is offline
Banned
protagonist's Avatar
Join Date: May 2003
Location: CAW
Posts: 5,586
protagonist is on a distinguished road
Send a message via AIM to protagonist Send a message via MSN to protagonist
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.
Reply With Quote
  #15  
Old 10-18-2005, 08:20 PM
Dach Dach is offline
call me Chad, it's cooler
Dach's Avatar
Join Date: Aug 2002
Posts: 1,899
Dach is on a distinguished road
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.
__________________
Scripting Documents:Old Script Documentation-Movement Tutorial

Last edited by Dach; 10-18-2005 at 08:48 PM..
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 02:27 PM.


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