1. /*
  2. * @(#)Number.java 1.24 01/11/29
  3. *
  4. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.lang;
  8. /**
  9. * The abstract class <code>Number</code> is the superclass of
  10. * classes <code>Byte</code>, <code>Double</code>, <code>Float</code>,
  11. * <code>Integer</code>, <code>Long</code>, and <code>Short</code>.
  12. * <p>
  13. * Subclasses of <code>Number</code> must provide methods to convert
  14. * the represented numeric value to <code>byte</code>, <code>double</code>,
  15. * <code>float</code>, <code>int</code>, <code>long</code>, and
  16. * <code>short</code>.
  17. *
  18. * @author Lee Boynton
  19. * @author Arthur van Hoff
  20. * @version 1.24, 11/29/01
  21. * @see java.lang.Byte
  22. * @see java.lang.Double
  23. * @see java.lang.Float
  24. * @see java.lang.Integer
  25. * @see java.lang.Long
  26. * @see java.lang.Short
  27. * @since JDK1.0
  28. */
  29. public abstract class Number implements java.io.Serializable {
  30. /**
  31. * Returns the value of the specified number as an <code>int</code>.
  32. * This may involve rounding.
  33. *
  34. * @return the numeric value represented by this object after conversion
  35. * to type <code>int</code>.
  36. */
  37. public abstract int intValue();
  38. /**
  39. * Returns the value of the specified number as a <code>long</code>.
  40. * This may involve rounding.
  41. *
  42. * @return the numeric value represented by this object after conversion
  43. * to type <code>long</code>.
  44. */
  45. public abstract long longValue();
  46. /**
  47. * Returns the value of the specified number as a <code>float</code>.
  48. * This may involve rounding.
  49. *
  50. * @return the numeric value represented by this object after conversion
  51. * to type <code>float</code>.
  52. */
  53. public abstract float floatValue();
  54. /**
  55. * Returns the value of the specified number as a <code>double</code>.
  56. * This may involve rounding.
  57. *
  58. * @return the numeric value represented by this object after conversion
  59. * to type <code>double</code>.
  60. */
  61. public abstract double doubleValue();
  62. /**
  63. * Returns the value of the specified number as a <code>byte</code>.
  64. * This may involve rounding or truncation.
  65. *
  66. * @return the numeric value represented by this object after conversion
  67. * to type <code>byte</code>.
  68. * @since JDK1.1
  69. */
  70. public byte byteValue() {
  71. return (byte)intValue();
  72. }
  73. /**
  74. * Returns the value of the specified number as a <code>short</code>.
  75. * This may involve rounding or truncation.
  76. *
  77. * @return the numeric value represented by this object after conversion
  78. * to type <code>short</code>.
  79. * @since JDK1.1
  80. */
  81. public short shortValue() {
  82. return (short)intValue();
  83. }
  84. /** use serialVersionUID from JDK 1.0.2 for interoperability */
  85. private static final long serialVersionUID = -8742448824652078965L;
  86. }