title: Lua - Detecting integers
body: <p>Lua behaves as follows :</p>
  
  <pre><code>print( 1 ) -- prints 1
  print( 1.0 ) -- prints 1.0
  </code></pre>
  
  <p>Since Lua is using <code>lua_Number</code>, which is a floating point value (either float or double), for all number types (i.e both integers and reals), I guess it somehow keeps track of the actual nature of a number value, or else <code>print( 1 )</code> would print <code>1.0</code> since the information that that <code>1</code> is an integer would be lost when casting 1 to <code>lua_Number</code> at some point in the Lua's code.</p>
  
  <p>Is there a way, using the C API of Lua 5.3.2, to detect whether a <code>lua_Number</code> was originally an integer or a real ?</p>
  
  <p>Say I want to code a native function expecting either an integer or a real. How can I know, when poping my parameters, if the given value was <code>1</code> or <code>1.0</code> ?</p>
  
  <p>Thanks.</p>
  
  <p>PS : I already saw this answer : <a href="https://stackoverflow.com/questions/25196042/test-if-lua-number-is-integer-or-float">Test if Lua number is integer or float</a> but it doesn't solve my problem since checking if <code>number == (int) number</code> would indicate that any real like <code>N.0</code> would be an integer.</p>