<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: The occasional annoyance of integer math.</title>
	<atom:link href="http://www.frogdice.com/muckbeast/game_design/the-occasional-annoyance-of-integer-math.html/feed" rel="self" type="application/rss+xml" />
	<link>http://www.frogdice.com/muckbeast/game_design/the-occasional-annoyance-of-integer-math.html</link>
	<description>Game Design, MUDs, MMOs, and Virtual Worlds</description>
	<lastBuildDate>Thu, 09 Feb 2012 18:34:32 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Ila Staniszewski</title>
		<link>http://www.frogdice.com/muckbeast/game_design/the-occasional-annoyance-of-integer-math.html/comment-page-1#comment-8030</link>
		<dc:creator>Ila Staniszewski</dc:creator>
		<pubDate>Fri, 06 Jan 2012 21:39:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.frogdice.com/muckbeast/?p=457#comment-8030</guid>
		<description>We&#039;re a gaggle of volunteers and opening a new scheme in our community. Your site provided us with useful info to paintings on. You&#039;ve performed a formidable process and our entire neighborhood shall be grateful to you.</description>
		<content:encoded><![CDATA[<p>We&#8217;re a gaggle of volunteers and opening a new scheme in our community. Your site provided us with useful info to paintings on. You&#8217;ve performed a formidable process and our entire neighborhood shall be grateful to you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tragamonedas</title>
		<link>http://www.frogdice.com/muckbeast/game_design/the-occasional-annoyance-of-integer-math.html/comment-page-1#comment-7630</link>
		<dc:creator>Tragamonedas</dc:creator>
		<pubDate>Sun, 30 Oct 2011 07:42:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.frogdice.com/muckbeast/?p=457#comment-7630</guid>
		<description>grande tosimpe de icoibamot y entra con brado cetopria. argues a mimondu y glicadeto treras con blembuvo engrapalo!</description>
		<content:encoded><![CDATA[<p>grande tosimpe de icoibamot y entra con brado cetopria. argues a mimondu y glicadeto treras con blembuvo engrapalo!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Muckbeast</title>
		<link>http://www.frogdice.com/muckbeast/game_design/the-occasional-annoyance-of-integer-math.html/comment-page-1#comment-3815</link>
		<dc:creator>Muckbeast</dc:creator>
		<pubDate>Wed, 31 Mar 2010 04:01:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.frogdice.com/muckbeast/?p=457#comment-3815</guid>
		<description>Xeno and Bryan: I don&#039;t have much to add other than to thank you for posting. Great insights into how work around float/int issues. :)</description>
		<content:encoded><![CDATA[<p>Xeno and Bryan: I don&#8217;t have much to add other than to thank you for posting. Great insights into how work around float/int issues. <img src='http://www.frogdice.com/muckbeast/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: BryanM</title>
		<link>http://www.frogdice.com/muckbeast/game_design/the-occasional-annoyance-of-integer-math.html/comment-page-1#comment-3797</link>
		<dc:creator>BryanM</dc:creator>
		<pubDate>Mon, 22 Mar 2010 22:23:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.frogdice.com/muckbeast/?p=457#comment-3797</guid>
		<description>Floating point variables are the bane of my existence.

A problem is the bigger a number gets, the less precise they become. This is obvious when you think about it - it&#039;s essentially a binary version of scientific notation, crammed into a few bits like an entire ham into a small can.

So when you want to subtract, say, .6345 from something... it decides to go nuts and in reality subtract .64, or something even more perverse than that.

In a platformer thing I&#039;m making, I started off using floats, in my childish naive innocence. The glitchiness became apparent once I started generating screens - seems would appear, inevitably, between tiles where the rounding on floats got funky.

I tried some funky approaches to solving this - having tiles overlap one another very slightly (like .01 of a pixel) etc, but the solution was very simple: don&#039;t use floats, use fixed point numbers instead.

The largest data types can store something like the distance to Pluto in meters or something - so what is the benefit of floaty point in this situation?

And in what situations are floating point variables the best tool for the job? In a nuclear bomb simulator, for example, I can&#039;t imagine they wouldn&#039;t want very precise values instead of whatever arbitrary values the IEEE Standard permits...</description>
		<content:encoded><![CDATA[<p>Floating point variables are the bane of my existence.</p>
<p>A problem is the bigger a number gets, the less precise they become. This is obvious when you think about it &#8211; it&#8217;s essentially a binary version of scientific notation, crammed into a few bits like an entire ham into a small can.</p>
<p>So when you want to subtract, say, .6345 from something&#8230; it decides to go nuts and in reality subtract .64, or something even more perverse than that.</p>
<p>In a platformer thing I&#8217;m making, I started off using floats, in my childish naive innocence. The glitchiness became apparent once I started generating screens &#8211; seems would appear, inevitably, between tiles where the rounding on floats got funky.</p>
<p>I tried some funky approaches to solving this &#8211; having tiles overlap one another very slightly (like .01 of a pixel) etc, but the solution was very simple: don&#8217;t use floats, use fixed point numbers instead.</p>
<p>The largest data types can store something like the distance to Pluto in meters or something &#8211; so what is the benefit of floaty point in this situation?</p>
<p>And in what situations are floating point variables the best tool for the job? In a nuclear bomb simulator, for example, I can&#8217;t imagine they wouldn&#8217;t want very precise values instead of whatever arbitrary values the IEEE Standard permits&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Xenovore</title>
		<link>http://www.frogdice.com/muckbeast/game_design/the-occasional-annoyance-of-integer-math.html/comment-page-1#comment-3796</link>
		<dc:creator>Xenovore</dc:creator>
		<pubDate>Mon, 22 Mar 2010 21:25:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.frogdice.com/muckbeast/?p=457#comment-3796</guid>
		<description>After re-reading the original post, I thought of something else with regard to damage output/input that might be helpful.

I don&#039;t know how your combat is segmented, i.e. is it turn-based or real-time? But either way, the combat can be segmented into periods, &quot;sub-rounds&quot; or &quot;ticks&quot;, to minimize the rounding error -- during each tick, damage is accumulated but not applied until the end of the tick. 

So, for example, let&#039;s say the combat tick is 1 second long; and during that period 3 attacks are made, mitigated by the 20% damage resistance:

1) 12 HP * 0.20 = 2.4 HP.
2) 18 HP * 0.20 = 3.6 HP.
3) 9 HP * 0.20 = 1.8 HP.

Total damage is 7.8 HP at the end of the tick. Then it&#039;s rounded and applied for 8 HP. Another benefit is that the damage resistance only needs to apply once, i.e. 12 + 18 + 9 = 39 * 0.20 = 7.8.</description>
		<content:encoded><![CDATA[<p>After re-reading the original post, I thought of something else with regard to damage output/input that might be helpful.</p>
<p>I don&#8217;t know how your combat is segmented, i.e. is it turn-based or real-time? But either way, the combat can be segmented into periods, &#8220;sub-rounds&#8221; or &#8220;ticks&#8221;, to minimize the rounding error &#8212; during each tick, damage is accumulated but not applied until the end of the tick. </p>
<p>So, for example, let&#8217;s say the combat tick is 1 second long; and during that period 3 attacks are made, mitigated by the 20% damage resistance:</p>
<p>1) 12 HP * 0.20 = 2.4 HP.<br />
2) 18 HP * 0.20 = 3.6 HP.<br />
3) 9 HP * 0.20 = 1.8 HP.</p>
<p>Total damage is 7.8 HP at the end of the tick. Then it&#8217;s rounded and applied for 8 HP. Another benefit is that the damage resistance only needs to apply once, i.e. 12 + 18 + 9 = 39 * 0.20 = 7.8.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Xenovore</title>
		<link>http://www.frogdice.com/muckbeast/game_design/the-occasional-annoyance-of-integer-math.html/comment-page-1#comment-3795</link>
		<dc:creator>Xenovore</dc:creator>
		<pubDate>Mon, 22 Mar 2010 20:55:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.frogdice.com/muckbeast/?p=457#comment-3795</guid>
		<description>Well, that&#039;s what I was alluding to... It makes sense to use floating point for those, rounding as necessary. It depends on what you want to do with them as well. 

In other words, for 0.4 HP, do you want to give the player the benefit and round down to 0, or always round up, so it&#039;s at least 1 HP? Personally, I think rounding to the nearest whole amount works fine for hit points.

In the case of currency, I imagine you&#039;d want to always round up -- that&#039;s essentially what we do with real world currency, e.g. if the smallest denomination were 5 cents, it&#039;s rather unlikely that something would cost $2.16; it would actually be bumped up to $2.20.</description>
		<content:encoded><![CDATA[<p>Well, that&#8217;s what I was alluding to&#8230; It makes sense to use floating point for those, rounding as necessary. It depends on what you want to do with them as well. </p>
<p>In other words, for 0.4 HP, do you want to give the player the benefit and round down to 0, or always round up, so it&#8217;s at least 1 HP? Personally, I think rounding to the nearest whole amount works fine for hit points.</p>
<p>In the case of currency, I imagine you&#8217;d want to always round up &#8212; that&#8217;s essentially what we do with real world currency, e.g. if the smallest denomination were 5 cents, it&#8217;s rather unlikely that something would cost $2.16; it would actually be bumped up to $2.20.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Muckbeast</title>
		<link>http://www.frogdice.com/muckbeast/game_design/the-occasional-annoyance-of-integer-math.html/comment-page-1#comment-3782</link>
		<dc:creator>Muckbeast</dc:creator>
		<pubDate>Fri, 19 Mar 2010 21:10:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.frogdice.com/muckbeast/?p=457#comment-3782</guid>
		<description>Fixed point math would be nice as well. 

But in game terms, sometimes you are still left with a &quot;what do I do now&quot; when you need to deduct .4 of a hit point from someone, or charge someone .6 of a unit of currency.</description>
		<content:encoded><![CDATA[<p>Fixed point math would be nice as well. </p>
<p>But in game terms, sometimes you are still left with a &#8220;what do I do now&#8221; when you need to deduct .4 of a hit point from someone, or charge someone .6 of a unit of currency.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Xenovore</title>
		<link>http://www.frogdice.com/muckbeast/game_design/the-occasional-annoyance-of-integer-math.html/comment-page-1#comment-3780</link>
		<dc:creator>Xenovore</dc:creator>
		<pubDate>Fri, 19 Mar 2010 20:28:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.frogdice.com/muckbeast/?p=457#comment-3780</guid>
		<description>In this day and age, limiting yourself to only integer math is rather like poking your eyes out because the sun is too bright -- it&#039;s &lt;i&gt;a&lt;/i&gt; solution, but hardly the &lt;i&gt;best&lt;/i&gt; solution. 

Use floating point where it makes sense, I say (like in your examples above). With modern processors, the performance gain of integers over floats is minimal. And floating point is unavoidable anyway if you&#039;re doing any 3D graphics...

But, if you feel you must stick primarily with integers, you could use &lt;a href=&quot;http://en.wikipedia.org/wiki/Fixed-point_arithmetic&quot; rel=&quot;nofollow&quot;&gt;fixed-point math&lt;/a&gt;...</description>
		<content:encoded><![CDATA[<p>In this day and age, limiting yourself to only integer math is rather like poking your eyes out because the sun is too bright &#8212; it&#8217;s <i>a</i> solution, but hardly the <i>best</i> solution. </p>
<p>Use floating point where it makes sense, I say (like in your examples above). With modern processors, the performance gain of integers over floats is minimal. And floating point is unavoidable anyway if you&#8217;re doing any 3D graphics&#8230;</p>
<p>But, if you feel you must stick primarily with integers, you could use <a href="http://en.wikipedia.org/wiki/Fixed-point_arithmetic" rel="nofollow">fixed-point math</a>&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Muckbeast</title>
		<link>http://www.frogdice.com/muckbeast/game_design/the-occasional-annoyance-of-integer-math.html/comment-page-1#comment-3772</link>
		<dc:creator>Muckbeast</dc:creator>
		<pubDate>Fri, 19 Mar 2010 09:07:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.frogdice.com/muckbeast/?p=457#comment-3772</guid>
		<description>That last example is brilliant, Brian. I occasionally have a good idea like that where I use a math &quot;trick&quot; (they seem like tricks to me at least) to use numbers to store data in a complicated way.

Reading your example, and thinking of a few of my own, just amplifies my lament for such poor math education in high school. What a loss. :(</description>
		<content:encoded><![CDATA[<p>That last example is brilliant, Brian. I occasionally have a good idea like that where I use a math &#8220;trick&#8221; (they seem like tricks to me at least) to use numbers to store data in a complicated way.</p>
<p>Reading your example, and thinking of a few of my own, just amplifies my lament for such poor math education in high school. What a loss. <img src='http://www.frogdice.com/muckbeast/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian 'Psychochild' Green</title>
		<link>http://www.frogdice.com/muckbeast/game_design/the-occasional-annoyance-of-integer-math.html/comment-page-1#comment-3770</link>
		<dc:creator>Brian 'Psychochild' Green</dc:creator>
		<pubDate>Fri, 19 Mar 2010 03:59:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.frogdice.com/muckbeast/?p=457#comment-3770</guid>
		<description>&lt;i&gt;Meridian 59&lt;/i&gt;&#039;s scripting system uses integer math, too.  There&#039;s a bunch of tricks you learn while doing that. For example, do multiplications before divisions to keep rounding from throwing off the values in a complex equation.  Knowing how to factor equations was useful.

Integer math also made it easier to store multiple values in less space.  M59&#039;s spells/skills are stored as a single number: the first part is the spell/skill ID, and the last two digits were your proficiency.  That meant that the whole value could be stored in one integer.  value / 100 = skill/spell ID.  value modulo 100 = proficiency.</description>
		<content:encoded><![CDATA[<p><i>Meridian 59</i>&#8217;s scripting system uses integer math, too.  There&#8217;s a bunch of tricks you learn while doing that. For example, do multiplications before divisions to keep rounding from throwing off the values in a complex equation.  Knowing how to factor equations was useful.</p>
<p>Integer math also made it easier to store multiple values in less space.  M59&#8217;s spells/skills are stored as a single number: the first part is the spell/skill ID, and the last two digits were your proficiency.  That meant that the whole value could be stored in one integer.  value / 100 = skill/spell ID.  value modulo 100 = proficiency.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

