Weird TDP costs 10/02/2010 06:28 AM CDT
Race: Gor'Tog
Stamina: 17

>train
It would take 35 time development points to advance stamina one rank...

How do you have a rounding error when multiplying two integers less than 20?
Reply
Re: Weird TDP costs 10/02/2010 06:32 AM CDT
>How do you have a rounding error when multiplying two integers less than 20?

I'll just stop you here. Numbers aren't rounded in DR, they're truncated.




>describe boar
It's a boar. It doesn't like you.
Reply
Re: Weird TDP costs 10/02/2010 06:34 AM CDT
> I'll just stop you here. Numbers aren't rounded in DR, they're truncated.

In every case where the math is working out correctly, yes. My point was, how does the system conclude that 17 x2 = 35?
Reply
Re: Weird TDP costs 10/02/2010 06:34 AM CDT
Integer math FTW!

-Raesh

"Ever notice that B.A.'s flavor text swells in direct proportion to how much one of our characters is getting screwed?" - Brian Van Hoose
Reply
Re: Weird TDP costs 10/02/2010 06:37 AM CDT
>>How do you have a rounding error when multiplying two integers less than 20?

The formula is (CURRENT_STAT x 3) + (TDP_MODIFIER + (CURRENT_STAT/2)), but it rounds down "CURRENT_STAT/2" part.

So while...

(17 * 3) + ( -2 (17/2)) -> (51) + (-2(8.5)) -> 51 + (-17) -> 51 - 17 = 34

It actually goes...

(17 * 3) + ( -2 (17/2)) -> (51) + (-2(8)) -> 51 + (-16) -> 51 - 16 = 35



"We're not "out to get you," we're here to enhance your playing experience with extreme prejudice.," DR-ARMIFER
Reply
Re: Weird TDP costs 10/02/2010 06:44 AM CDT
I was in the middle of writing that up - but PB saved me the trouble.

Bottom line: With integer math order of operation REALLY matters. For what it's worth while you are paying (slightly) more here due to order of operation, you're paying slightly less in the same scenario for the stats you're penalized in.

-Raesh

"Ever notice that B.A.'s flavor text swells in direct proportion to how much one of our characters is getting screwed?" - Brian Van Hoose
Reply
Re: Weird TDP costs 10/02/2010 06:53 AM CDT
> The formula is (CURRENT_STAT x 3) + (TDP_MODIFIER + (CURRENT_STAT/2)), but it rounds down "CURRENT_STAT/2" part.

And this is why you usually do division last to minimize such errors. Silly me for assuming that DR would do that. Thanks.

> For what it's worth while you are paying (slightly) more here due to order of operation, you're paying slightly less in the same scenario for the stats you're penalized in.

Even were I not, we're talking ~90 tdps per such stat over the character's entire life. I'm not going to lose sleep over it.
Reply
Re: Weird TDP costs 10/02/2010 07:02 AM CDT
> ~90 tdps

45.
Reply
Re: Weird TDP costs 10/02/2010 07:02 AM CDT
>>And this is why you usually do division last to minimize such errors.

It's not an error if it's intentional. I don't think any GMs who made the TDP formula or any other formulas involving division were going "woops, can't have that there!" when it was being created.

Any kind of division would result in rounding down having to take place at some point or another.



"We're not "out to get you," we're here to enhance your playing experience with extreme prejudice.," DR-ARMIFER
Reply
Re: Weird TDP costs 10/02/2010 07:07 AM CDT
> It's not an error if it's intentional

Fair enough.
Reply
Re: Weird TDP costs 10/02/2010 07:56 AM CDT
I'm fairly sleepy, so forgive me if this overlooks something silly, but PB makes a good point.

Look at some easy rearrangements of that formula, and you're going to end up with the same issue of integer math.

Example:

((6 + Stat mod) * current stat ) / 2 (Division last)

In the case of - 2 and an odd stat (So even times an odd, gives us even) this fixes our rounding error. But two odd values (Such as a -3 mod) we're back to the division causing an error.

The only way you can realistically eliminate something like this while staying in integer math is by using fake decimal points.

(((CURRENT_STAT * 100) x 3) + (TDP_MODIFIER + ((CURRENT_STAT * 100)/2))) / 100

Which removes the rounding error in this case, however this isn't always a viable solution since it can easily push you into overflow issues.

-Raesh

"Ever notice that B.A.'s flavor text swells in direct proportion to how much one of our characters is getting screwed?" - Brian Van Hoose
Reply
Re: Weird TDP costs 10/02/2010 08:06 AM CDT
> In the case of - 2 and an odd stat (So even times an odd, gives us even) this fixes our rounding error. But two odd values (Such as a -3 mod) we're back to the division causing an error.

Sure, but that's an error that's unavoidable. The result under real division (real as in real numbers, not suggesting that the other is fake) isn't an integer, so there has to be a change. This is an error we'd have under any system. On the other hand, only unavoidable errors occur in your reformulation (where an error means the integer arithmetic result isn't equal to the real arithmetic result).
Reply
Re: Weird TDP costs 10/02/2010 12:25 PM CDT
If this 'issue' bothers you, whatever you do don't dig deeper.





>describe boar
It's a boar. It doesn't like you.
Reply
Re: Weird TDP costs 10/02/2010 03:06 PM CDT
While it's true the division last version involves rounding any way you slice it, the result is different depending on if you're using integer math or not.

((6 + Stat mod) * current stat ) / 2 (Division last)

As we've established using -2 and 17, this works. However what happens if we use -3?

((6 - 3) * 17) / 2 = (3 * 17) / 2 = 51 / 2 = 25.5

Now, under normal math - that rounds up to 26. Under Integer math that rounds down to 25.

Anyhow - I'm not sure how much more there is to be gained in this conversation. DR uses integer math. Integer math causes rounding in non-intuitive ways sometimes. Not every DR system considers this limitation in the way they perhaps should -- it's a very easy mistake to make.

-Raesh

"Ever notice that B.A.'s flavor text swells in direct proportion to how much one of our characters is getting screwed?" - Brian Van Hoose
Reply
Re: Weird TDP costs 10/02/2010 04:03 PM CDT
Floating point has a similar issue: loss of precision.

You have to be careful how you construct floating point algorithms in order to maximize the number of significant digits of accuracy.

Even adding two numbers can cause the loss of significant digits of accuracy if not handled correctly and yield very large errors in iterative calculations.

Making programs that don't lose accuracy over iterating can be hellishly hard, especially when compilers sneak behind your back and reorder things.

Numerical analysis was so much fun!

-pete
Reply
Re: Weird TDP costs 10/05/2010 08:05 AM CDT
NERDS!


-=Issus=-
Reply