The Tournament Director Forums
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
May 22, 2013, 04:46:13 PM
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Search:
Advanced search
17110
Posts in
3140
Topics by
1519
Members
Latest Member:
jwAVqbJX4x
Back to The Tournament Director main site
The Tournament Director Forums
Main
Help Me
Prize Rounding Error?
« previous
next »
Pages:
[
1
]
Author
Topic: Prize Rounding Error? (Read 235 times)
Double Eagle
Newbie
Posts: 16
Prize Rounding Error?
«
on:
November 08, 2011, 10:56:30 AM »
I used ver. 3.0 for the first time this weekend. When calculating the prizes for a six places, I specified to round down to the nearest $5. The last place prize was caluculated to be $124. The summary was correct however and did not reflect that a $1 was omitted. I have never seen this in ver. 2.
«
Last Edit: November 08, 2011, 11:04:44 AM by Double Eagle
»
Logged
Corey Cooper
Administrator
Hero Member
Posts: 4265
Re: Prize Rounding Error?
«
Reply #1 on:
November 08, 2011, 10:58:08 AM »
Can you provide the tournament file so I can look at it? You can email it to
support@thetournamentdirector.net
, or attach it to a post here if you're comfortable with that.
Logged
Corey Cooper
Administrator
Hero Member
Posts: 4265
Re: Prize Rounding Error?
«
Reply #2 on:
November 09, 2011, 10:08:18 PM »
Thanks for sending the tournament. This is indeed a rounding error. The actual value of 6th place as computed by the software is 124.99999999999998. When the software displays the amount in a monetary format (with currency symbol and rounded to 2 decimal places), it comes out as $125.00. In your tournament screen, you're using the
<vprizes>
token with the attribute
roundOff="true"
. Round off means drop the decimal places, which unfortunately comes out to $124.
This is a rounding error present in many languages, Javascript being one of them unfortunately. It happens with non-integers when they are converted between binary and decimal representations. The trick is to avoid fractional numbers in computation. Not always possible, but for an application like the TD where the primary calculations are done with money or similar values (2 decimal places), you can multiply all values by 100 and round them off. When you display them, you just divide by 100. This avoids the rounding errors entirely. Were I to write the TD all over again, I would definitely do it this way. Unfortunately it's a tad bit late now.
I'll look at the prizes code to see if I can avoid it. The only workaround I can think of is to turn off the
roundOff
attribute.
Logged
Corey Cooper
Administrator
Hero Member
Posts: 4265
Re: Prize Rounding Error?
«
Reply #3 on:
November 09, 2011, 10:42:19 PM »
I found a quick workaround for this (fixed it, but there's a better fix to be done at a later time). I published patch 4 to fix it. If you use the TD while online, it should automatically download the fix.
Logged
Double Eagle
Newbie
Posts: 16
Re: Prize Rounding Error?
«
Reply #4 on:
November 09, 2011, 11:01:01 PM »
Thanks for the prompt reply and fix!
Logged
Pages:
[
1
]
« previous
next »
Jump to:
Please select a destination:
-----------------------------
Main
-----------------------------
=> Suggestions
=> Help Me
=> Templates, Layouts and Sounds
=> General Discussion
=> Beta Testing
Loading...