<div dir="ltr"><div><div></div>Conditionalizing on &quot;if (0.5 == (time_t) 0.5)&quot; is a possibility (albeit ugly).<br><br></div><div>    --ado<br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jul 8, 2013 at 6:00 PM, Andy Heninger <span dir="ltr">&lt;<a href="mailto:aheninger@google.com" target="_blank">aheninger@google.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Whatever the code ends up being, it would be helpful if it produced no compiler warnings with the warning level cranked up to the maximum, on either gcc or clang.<span class="HOEnZb"><font color="#888888"><div>
<br></div><div>  -- Andy</div><div><br></div>
</font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jul 8, 2013 at 2:49 PM, Alan Barrett <span dir="ltr">&lt;<a href="mailto:apb@cequrux.com" target="_blank">apb@cequrux.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>On Mon, 08 Jul 2013, Paul_Koning@Dell.com wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Perhaps this will work without either a compiler warning or potential loss of precision:<br>
<br>
          seconds = tdays * SECSPERDAY + (time_t)0.5;<br>
<br>
--apb (Alan Barrett)<br>
</blockquote>
<br>
I rather doubt it.  Casting 0.5 to an integer type (as time_t is) ends up adding 0 or 1, but not 0.5.<br>
</blockquote>
<br></div>
The whole point of adding 0.5 before converting from time_t to int_fast32_t is to round up if time_t happens to be a floating point type, and to do nothing if time_t happens to be an integral type.  You can&#39;t assume that time_t is an integral type.<div>

<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
How about (tdays * SECSPERDAY * 2 + 1) / 2;   ?<br>
</blockquote>
<br></div>
Multiplying by 2 might overflow the available range.  (I have not checked whether there are reasons why it would always be safe.) <br>
--apb (Alan Barrett)<br>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>