<h2>Java's Numeric Literals</h2> <p align=center><table border> <tr><td><tt>null</tt><td>an as yet uncreated, or an invalid, Object Reference <tr><td><tt>true, false</tt><td>the two possible values of a boolean variable <tr><td><tt>29</tt><td>int constant - decimal representation <tr><td><tt>035</tt><td>int constant - octal (base 8) representation <tr><td><tt>0x1D</tt><td>int constant - hexadecimal (base 16) representation </table> <p align=justify> When an <tt>int</tt> constant (as above) is assigned to a <tt>byte</tt> variable or a <tt>short</tt> variable, it is automatically converted to <tt>byte</tt> or <tt>short</tt> as appropriate (provided its value lies within the valid range for that type). <pre><tt>29L long</tt> constant - decimal representation <tt>035L long</tt> constant - octal (base 8) representation <tt>0x1DL long</tt> constant - hexadecimal (base 16) representation <tt>18.0F float</tt> constant - the <tt>.0</tt> is optional, the <tt>F</tt> is mandatory <tt>1.8E1F float</tt> constant - exponent form, the F is mandatory <tt>.18E2F float</tt> constant - exponent form, the F is mandatory <tt>18.0D double</tt> constant - the .0 and the D are optional <tt>1.8E1D double</tt> constant - exponent form the D is optional <tt>.18E2D double</tt> constant - exponent form the D is optional</pre> <p align=justify> Zero can be positive or negative. These are numerically equal but give different results in certain calculations eg: <p align=center><img src=java02.gif width=203 height=35> <p align=justify> A non-float constant such as a double cannot be assigned to a float variable. You must use a float literal viz: <pre>float x = 18.9F;</pre> <hr> &copy; 1998 Robert John Morton