Sorry for double-messaging, but i need to rephrase what i said: unsigned int has twice as many possible values than signed int and a signed int would cause overflows more often than unsigned int.<br><br><div class="gmail_quote">
On Thu, Jul 22, 2010 at 4:09 PM, Nuno Silva <span dir="ltr">&lt;<a href="mailto:little.coding.fox@gmail.com">little.coding.fox@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Problem is that unsigned int has more storage for positive values than signed int (by about half), not to mention all time libraries and specifications go with unsigned values too.<br><br><div class="gmail_quote"><div><div>
</div><div class="h5">On Thu, Jul 22, 2010 at 4:02 PM, Stefan Ludewig <span dir="ltr">&lt;<a href="mailto:stefan.ludewig@exitgames.com" target="_blank">stefan.ludewig@exitgames.com</a>&gt;</span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div><div></div><div class="h5">








<div link="blue" vlink="purple" lang="DE">

<div>

<p class="MsoNormal">Hi all.</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal"><span lang="EN-US">What is the reason enet uses unsigned int
and these time overflow macros in time.h?</span></p>

<p class="MsoNormal"><span lang="EN-US">I enet would simply use signed int, these
macros would not be needed at all.</span></p>

<p class="MsoNormal"><span lang="EN-US">For example if we have a time INT_MAX and a
second one INT_MIN , 1ms later, directly after the overflow, INT_MIN-INT_MAX
would result in the correct difference 1 and INT_MAX-INT_MIN in the correct
difference -1. No need for the use of ENET_TIME_DIFFERENCE at all for signed
int.</span></p>

<p class="MsoNormal"><span lang="EN-US">On the other hand, if we call
ENET_TIME_DIFFERENCE(a, b) with a==1 and b==2, the result is b-a -&gt; 1,
although the correct result would have been -1.</span></p>

<p class="MsoNormal"><span lang="EN-US">If some functions need unsigned times or
return unsigned times, you could simply them from/to signed int, and all would
be fine.</span></p>

<p class="MsoNormal"><span lang="EN-US">So I do not see any advantage in using
unsigned int and time.h macros instead of simply use signed int. Can you tell
me the reasons for the unsigned + time.h solution?</span></p>

<p class="MsoNormal"><span lang="EN-US"> </span></p>

<p class="MsoNormal"><span lang="EN-US">Thx,</span></p>

<p class="MsoNormal"><span lang="EN-US">Stefan.</span></p>

<p class="MsoNormal"><span lang="EN-US"> </span></p>

</div>

</div>


<br></div></div>_______________________________________________<br>
ENet-discuss mailing list<br>
<a href="mailto:ENet-discuss@cubik.org" target="_blank">ENet-discuss@cubik.org</a><br>
<a href="http://lists.cubik.org/mailman/listinfo/enet-discuss" target="_blank">http://lists.cubik.org/mailman/listinfo/enet-discuss</a><br>
<br></blockquote></div><br>
</blockquote></div><br>