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