<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.3.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: Star Ratings</title>
	<link>http://leahculver.com/2007/04/19/star-ratings/</link>
	<description>leahculver.com</description>
	<pubDate>Thu, 21 Aug 2008 23:27:07 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.2</generator>
		<item>
		<title>By: Tom</title>
		<link>http://leahculver.com/2007/04/19/star-ratings/#comment-940</link>
		<dc:creator>Tom</dc:creator>
		<pubDate>Mon, 23 Apr 2007 16:07:03 +0000</pubDate>
		<guid>http://leahculver.com/2007/04/19/star-ratings/#comment-940</guid>
		<description>A perfect example of why everyone's first course in programming should be Fortran.</description>
		<content:encoded><![CDATA[<p>A perfect example of why everyone&#8217;s first course in programming should be Fortran.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sam Purtill</title>
		<link>http://leahculver.com/2007/04/19/star-ratings/#comment-939</link>
		<dc:creator>Sam Purtill</dc:creator>
		<pubDate>Sat, 21 Apr 2007 21:48:36 +0000</pubDate>
		<guid>http://leahculver.com/2007/04/19/star-ratings/#comment-939</guid>
		<description>Hey Leah... Why Django over Ruby on Rails? I picked Django too, and we all have our reasons. Write a post about it!!!</description>
		<content:encoded><![CDATA[<p>Hey Leah&#8230; Why Django over Ruby on Rails? I picked Django too, and we all have our reasons. Write a post about it!!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: leah.culver</title>
		<link>http://leahculver.com/2007/04/19/star-ratings/#comment-938</link>
		<dc:creator>leah.culver</dc:creator>
		<pubDate>Fri, 20 Apr 2007 18:52:36 +0000</pubDate>
		<guid>http://leahculver.com/2007/04/19/star-ratings/#comment-938</guid>
		<description>Alexander - seems to me like something people would remember if they had used it before. I'd never had to round like that before and I kept thinking that there was some way to do it mathematically, but I couldn't remember how. I hope it's not as important to know the best solution as it is to know a better solution exists.

Richard and Christopher - I suppose I was being too generous with .7. I don't mind the rounding difference and I doubt the cheeseburgers will either.

Everybody - Thanks so much for the help! I suppose I could have looked around more for the solution but now I feel like my blog was actually useful.</description>
		<content:encoded><![CDATA[<p>Alexander - seems to me like something people would remember if they had used it before. I&#8217;d never had to round like that before and I kept thinking that there was some way to do it mathematically, but I couldn&#8217;t remember how. I hope it&#8217;s not as important to know the best solution as it is to know a better solution exists.</p>
<p>Richard and Christopher - I suppose I was being too generous with .7. I don&#8217;t mind the rounding difference and I doubt the cheeseburgers will either.</p>
<p>Everybody - Thanks so much for the help! I suppose I could have looked around more for the solution but now I feel like my blog was actually useful.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Richard Kiss</title>
		<link>http://leahculver.com/2007/04/19/star-ratings/#comment-937</link>
		<dc:creator>Richard Kiss</dc:creator>
		<pubDate>Fri, 20 Apr 2007 18:11:36 +0000</pubDate>
		<guid>http://leahculver.com/2007/04/19/star-ratings/#comment-937</guid>
		<description>Here's an idea:

stars = float(str(round(float(star_sum)/num_raters,1)).split('.')[0]) + {'0':0, '1':0, '2':0, '3':0.5, '4':0.5, '5':0.5, '6':0.5, '7':0.5, '8':1.0,'9':1.0}[str(round(float(star_sum)/num_raters,1)).split('.')[1]]

or more concisely,

stars = round(float(star_sum+star_sum)/num_raters)/2</description>
		<content:encoded><![CDATA[<p>Here&#8217;s an idea:</p>
<p>stars = float(str(round(float(star_sum)/num_raters,1)).split(&#8217;.')[0]) + {&#8217;0&#8242;:0, &#8216;1&#8242;:0, &#8216;2&#8242;:0, &#8216;3&#8242;:0.5, &#8216;4&#8242;:0.5, &#8216;5&#8242;:0.5, &#8216;6&#8242;:0.5, &#8216;7&#8242;:0.5, &#8216;8&#8242;:1.0,&#8217;9&#8242;:1.0}[str(round(float(star_sum)/num_raters,1)).split(&#8217;.')[1]]</p>
<p>or more concisely,</p>
<p>stars = round(float(star_sum+star_sum)/num_raters)/2</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alexander Repty</title>
		<link>http://leahculver.com/2007/04/19/star-ratings/#comment-936</link>
		<dc:creator>Alexander Repty</dc:creator>
		<pubDate>Fri, 20 Apr 2007 08:13:35 +0000</pubDate>
		<guid>http://leahculver.com/2007/04/19/star-ratings/#comment-936</guid>
		<description>I gave this to some of my co-workers (system administrators and software developers) as a challenge. Only 2 out of 7 could get it right (both software developers - one of them an apprentice).

I immediately knew the solution when I finished reading the problem at hand, and I would have done it exactly like Bob did. I guess it's just the experience in solving problems like this one that enables you to see this solution.</description>
		<content:encoded><![CDATA[<p>I gave this to some of my co-workers (system administrators and software developers) as a challenge. Only 2 out of 7 could get it right (both software developers - one of them an apprentice).</p>
<p>I immediately knew the solution when I finished reading the problem at hand, and I would have done it exactly like Bob did. I guess it&#8217;s just the experience in solving problems like this one that enables you to see this solution.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bob Ippolito</title>
		<link>http://leahculver.com/2007/04/19/star-ratings/#comment-935</link>
		<dc:creator>Bob Ippolito</dc:creator>
		<pubDate>Fri, 20 Apr 2007 02:02:07 +0000</pubDate>
		<guid>http://leahculver.com/2007/04/19/star-ratings/#comment-935</guid>
		<description>In general you should never have to convert a number to a string. If you needed to get the fractional and whole parts of a float there's math.modf(someFloat) which returns (frac, whole). Anyway, I would probably just double the sum, round, then half it.


stars = 0.5 * round((2.0 * star_sum) / num_raters)</description>
		<content:encoded><![CDATA[<p>In general you should never have to convert a number to a string. If you needed to get the fractional and whole parts of a float there&#8217;s math.modf(someFloat) which returns (frac, whole). Anyway, I would probably just double the sum, round, then half it.</p>
<p>stars = 0.5 * round((2.0 * star_sum) / num_raters)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: J Taylor</title>
		<link>http://leahculver.com/2007/04/19/star-ratings/#comment-934</link>
		<dc:creator>J Taylor</dc:creator>
		<pubDate>Fri, 20 Apr 2007 01:55:25 +0000</pubDate>
		<guid>http://leahculver.com/2007/04/19/star-ratings/#comment-934</guid>
		<description>#I don't program in Python and I'm not sure if this code has the correct syntax
#Calculate rating out of 10
rating = round(star_sum*2/num_raters, 1)
#Calculate number of whole stars by integer division
whole_stars = rating // 2
#Calculate number of half stars by remainder
half_stars = rating % 2
#Combine into one number
stars = whole_stars + (half_stars * 0.5)</description>
		<content:encoded><![CDATA[<p>#I don&#8217;t program in Python and I&#8217;m not sure if this code has the correct syntax<br />
#Calculate rating out of 10<br />
rating = round(star_sum*2/num_raters, 1)<br />
#Calculate number of whole stars by integer division<br />
whole_stars = rating // 2<br />
#Calculate number of half stars by remainder<br />
half_stars = rating % 2<br />
#Combine into one number<br />
stars = whole_stars + (half_stars * 0.5)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Christopher Finke</title>
		<link>http://leahculver.com/2007/04/19/star-ratings/#comment-933</link>
		<dc:creator>Christopher Finke</dc:creator>
		<pubDate>Thu, 19 Apr 2007 22:58:08 +0000</pubDate>
		<guid>http://leahculver.com/2007/04/19/star-ratings/#comment-933</guid>
		<description>If you're willing to change your boundaries to .75 and .25 (rather than .7 and .3), you could do this:

stars = float(round(star_sum / num_raters * 2) / 2);</description>
		<content:encoded><![CDATA[<p>If you&#8217;re willing to change your boundaries to .75 and .25 (rather than .7 and .3), you could do this:</p>
<p>stars = float(round(star_sum / num_raters * 2) / 2);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: r</title>
		<link>http://leahculver.com/2007/04/19/star-ratings/#comment-932</link>
		<dc:creator>r</dc:creator>
		<pubDate>Thu, 19 Apr 2007 22:11:19 +0000</pubDate>
		<guid>http://leahculver.com/2007/04/19/star-ratings/#comment-932</guid>
		<description>might be misunderstanding what you're trying to do, but

formatting an average value to the nearest half (forgive the lack of python syntax):

round(AvgValue * 2) / 2

should work</description>
		<content:encoded><![CDATA[<p>might be misunderstanding what you&#8217;re trying to do, but</p>
<p>formatting an average value to the nearest half (forgive the lack of python syntax):</p>
<p>round(AvgValue * 2) / 2</p>
<p>should work</p>
]]></content:encoded>
	</item>
</channel>
</rss>
