Quote: "Microsoft recommends to use brackets too, but why if it is working without them in all languages? Let it go, it doesn't broken*
*don't fix it then!!!!!111111"
<Insert Dr Cox's "Wrong Song">
It does
NOT work in all languages.
In C and C++, the ^ symbol is a bitwise operation known as XOR (True only if 0 OR 1 when "XOR'ing" numbers) so it'll give you an answer which is chalk and cheese.
In DarkBasic, 8^1/3 will give you an answer of 2. However, 64^1/3 will give you 21 as an answer.
Try:
myval = 64^1/3
PRINT myval
Return value for "myval" is 21 which is not the cube root of 64 (it's 4).
So why? DBP does this: 8^1/3 = (8^1)/3 = 8/3 = 2. The casting system in DBP is about as stable as me when I drink too much. It performs lots of casts in the asm output (as previously posted by many users) somewhere in the process, it very poorly casts floats to ints by simply dropping everything beyond the decimal. This is seen in the 64^1/3 example as 64/3 = 21.3...4 but 8/3 = 2.6...7 and yet they become 21 and 2.
Proof?
myval = 1.99999
PRINT myval
Output is 1. Should be 2 but it's 1. DBP is a game-creation language. DBP is not intended as a maths, physics or science language which is partly why when a certain user made a DBP simulation to prove his outlandish (but interesting) physics theories, he got flamed -- no immolated -- by the forumites.
Now enough trolling me, Handy, you're only supposed to troll n00bs. Gawd ><
Are you satisfied with this answer? Please rate this article below
Rate this answer: []1 []2 []3 []4 []5
Click here to download free RAM torrents from TPB
You're a bad man!