![]() |
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. |
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) ) |
Quote:
|
Quote:
|
Quote:
Yea... I guess it's a bug. Who would want the cube of a negative number anyways? |
Quote:
Quote:
Quote:
Magic numbers are a totally different bunch of concepts. Quote:
Quote:
Quote:
|
Quote:
|
Quote:
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.) |
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. |
Quote:
|
Quote:
|
Quote:
φ 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. |
Quote:
|
Quote:
In any case, 0.333333... is still not 1/3. |
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.