title: Union for storing Timestamp. Comparing floats as integers
body: <p>While trying to wrap my brain around a custom game engine, I stumbled across a piece of code that looks rather odd to me:</p>
  
  <pre><code>union TimeStamp
  {
      f32 asFloat;
      u32 asUInt;
  
      TimeStamp() : asUInt(0U)
      {}
  
      TimeStamp(f32 floatValue) : asFloat(floatValue)
      {}
  
      operator u32() const { return this-&gt;asUInt; }
  
      inline const bool operator==(const TimeStamp&amp; other) const { return this-&gt;asUInt == other.asUInt; }
      inline const bool operator!=(const TimeStamp&amp; other) const { return this-&gt;asUInt != other.asUInt; }
  
      inline const bool operator&lt;(const TimeStamp&amp; other) const { return this-&gt;asFloat &lt; other.asFloat; }
      inline const bool operator&gt;(const TimeStamp&amp; other) const { return this-&gt;asFloat &gt; other.asFloat; }
  
  };
  </code></pre>
  
  <p>My c++ experience(which is quite limited) tells me that the only meaningful reason to have this union is to make equality operators to treat compared timestamps(otherwise float) as integers? If yes, then why would someone want that?</p>
  
  <p>I also don't understand what is the point of an integer type cast overload here, since we can't event init Timestamp with int?</p>
  
  <p><strong>Note:</strong> <code>f32</code> and <code>u32</code> are defined as <code>float_t</code> and <code>uint32_t</code></p>
  
  <p>Just in case, here is a link containing the definition: <a href="https://github.com/tobias-stein/EntityComponentSystem/blob/master/EntityComponentSystem/include/ECS/Platform.h" rel="nofollow noreferrer">https://github.com/tobias-stein/EntityComponentSystem/blob/master/EntityComponentSystem/include/ECS/Platform.h</a></p>