robobruin / freebiestats

Automatically exported from code.google.com/p/freebiestats
0 stars 0 forks source link

Pitching Ratios are incorrect for non-integral IP #5

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Yahoo! always uses the notation '5.1' to mean '5.33' and '2.2' to mean
'2.67' when it displays innings pitched totals.  Because of this, the code
to calculate ERA's and WHIP's for a pitcher don't work correctly, dividing
by (for example) 5 and 1/10th instead of 5 and 1/3rd.

Simple to fix; just use

var partialIP = ((columns[1].innerHTML * 10) % 10);
var realIP = (partialIP / 3) + (columns[1].innerHTML / 1);

and then use realIP as the denominators in the ERA and WHIP calculations.

Original issue reported on code.google.com by ethanher...@gmail.com on 16 Apr 2007 at 8:05

GoogleCodeExporter commented 9 years ago
thanks for reporting and suggesting the fix...I'll incorporate it in the next 
update

Original comment by robobr...@gmail.com on 17 Apr 2007 at 4:43

GoogleCodeExporter commented 9 years ago
only change I made was to add parseInt(columns[1].innerHTML) since
(columns[1].innerHTML / 1) will return a float.

Original comment by robobr...@gmail.com on 19 Apr 2007 at 6:14

GoogleCodeExporter commented 9 years ago

Original comment by robobr...@gmail.com on 4 May 2007 at 6:14