Bots and Simulations > Bot Tavern
Community Bots
Numsgil:
To follow up Eric's post, this is actually a good thing, because it means floating point errors won't bite you in the butt. Ie: 1 10 div 10 mult wouldn't necessarily equal 1 even if the stack handled decimals.
Moonfisher:
Heh... integer stack... ok
But if you divide 1 by 10 and then mulitply by 10 in a stack that handles decimals... why would the result not always be 1 ???
To the best of my memmory : 1/10 = 0.1, 0.1 * 10 = 1....
And if it didn't handle decimals... wouldn't it just always be 0 ?
Just not sure what you point was ? Why is it a good thing ? (Not saying it's a bad thing... just... nevermind...)
Numsgil:
See this link. Algebraically 1 10 div 10 mult should equal 1, but the realities of computers make it so this is not always the case. .1 is impossible to represent exactly using decimals on a computer. It's like 1/3 in decimal (ie: .3333333). Worse yet, the actual value of .1 will vary on different computers or programs or languages depending on all sorts of factors, some even on the hardware level.
By using integer math, the value you get will always be predictable and the same on all computers, hardware, etc. It might not always be "correct", but at least it's deterministically incorrect. You can compensate for it by doing a little fixed point math. ie: 1 1000 mult 10 div 10 mult 1000 div, which will always give you the correct answer of 1 even on different hardware, different languages, different drivers, etc.
bacillus:
Funny to see forums like these lead to conversations that have nothing to do with their title
Numsgil:
We (well, I really) have never been very good at staying on topic
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version