1 /*
2 * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
617 * {@code false} otherwise.
618 */
619 public boolean isInfinite() {
620 return isInfinite(value);
621 }
622
623 /**
624 * Returns a string representation of this {@code Double} object.
625 * The primitive {@code double} value represented by this
626 * object is converted to a string exactly as if by the method
627 * {@code toString} of one argument.
628 *
629 * @return a {@code String} representation of this object.
630 * @see java.lang.Double#toString(double)
631 */
632 public String toString() {
633 return toString(value);
634 }
635
636 /**
637 * Returns the value of this {@code Double} as a {@code byte} (by
638 * casting to a {@code byte}).
639 *
640 * @return the {@code double} value represented by this object
641 * converted to type {@code byte}
642 * @since JDK1.1
643 */
644 public byte byteValue() {
645 return (byte)value;
646 }
647
648 /**
649 * Returns the value of this {@code Double} as a
650 * {@code short} (by casting to a {@code short}).
651 *
652 * @return the {@code double} value represented by this object
653 * converted to type {@code short}
654 * @since JDK1.1
655 */
656 public short shortValue() {
657 return (short)value;
658 }
659
660 /**
661 * Returns the value of this {@code Double} as an
662 * {@code int} (by casting to type {@code int}).
663 *
664 * @return the {@code double} value represented by this object
665 * converted to type {@code int}
666 */
667 public int intValue() {
668 return (int)value;
669 }
670
671 /**
672 * Returns the value of this {@code Double} as a
673 * {@code long} (by casting to type {@code long}).
674 *
675 * @return the {@code double} value represented by this object
676 * converted to type {@code long}
677 */
678 public long longValue() {
679 return (long)value;
680 }
681
682 /**
683 * Returns the {@code float} value of this
684 * {@code Double} object.
685 *
686 * @return the {@code double} value represented by this object
687 * converted to type {@code float}
688 * @since JDK1.0
689 */
690 public float floatValue() {
691 return (float)value;
692 }
693
694 /**
695 * Returns the {@code double} value of this
696 * {@code Double} object.
697 *
698 * @return the {@code double} value represented by this object
699 */
700 public double doubleValue() {
701 return (double)value;
702 }
703
704 /**
705 * Returns a hash code for this {@code Double} object. The
706 * result is the exclusive OR of the two halves of the
707 * {@code long} integer bit representation, exactly as
708 * produced by the method {@link #doubleToLongBits(double)}, of
709 * the primitive {@code double} value represented by this
710 * {@code Double} object. That is, the hash code is the value
711 * of the expression:
712 *
713 * <blockquote>
714 * {@code (int)(v^(v>>>32))}
715 * </blockquote>
716 *
|
1 /*
2 * Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
617 * {@code false} otherwise.
618 */
619 public boolean isInfinite() {
620 return isInfinite(value);
621 }
622
623 /**
624 * Returns a string representation of this {@code Double} object.
625 * The primitive {@code double} value represented by this
626 * object is converted to a string exactly as if by the method
627 * {@code toString} of one argument.
628 *
629 * @return a {@code String} representation of this object.
630 * @see java.lang.Double#toString(double)
631 */
632 public String toString() {
633 return toString(value);
634 }
635
636 /**
637 * Returns the value of this {@code Double} as a {@code byte}
638 * after a narrowing primitive conversion.
639 *
640 * @return the {@code double} value represented by this object
641 * converted to type {@code byte}
642 * @jls 5.1.3 Narrowing Primitive Conversions
643 * @since JDK1.1
644 */
645 public byte byteValue() {
646 return (byte)value;
647 }
648
649 /**
650 * Returns the value of this {@code Double} as a {@code short}
651 * after a narrowing primitive conversion.
652 *
653 * @return the {@code double} value represented by this object
654 * converted to type {@code short}
655 * @jls 5.1.3 Narrowing Primitive Conversions
656 * @since JDK1.1
657 */
658 public short shortValue() {
659 return (short)value;
660 }
661
662 /**
663 * Returns the value of this {@code Double} as an {@code int}
664 * after a narrowing primitive conversion.
665 * @jls 5.1.3 Narrowing Primitive Conversions
666 *
667 * @return the {@code double} value represented by this object
668 * converted to type {@code int}
669 */
670 public int intValue() {
671 return (int)value;
672 }
673
674 /**
675 * Returns the value of this {@code Double} as a {@code long}
676 * after a narrowing primitive conversion.
677 *
678 * @return the {@code double} value represented by this object
679 * converted to type {@code long}
680 * @jls 5.1.3 Narrowing Primitive Conversions
681 */
682 public long longValue() {
683 return (long)value;
684 }
685
686 /**
687 * Returns the value of this {@code Double} as a {@code float}
688 * after a narrowing primitive conversion.
689 *
690 * @return the {@code double} value represented by this object
691 * converted to type {@code float}
692 * @jls 5.1.3 Narrowing Primitive Conversions
693 * @since JDK1.0
694 */
695 public float floatValue() {
696 return (float)value;
697 }
698
699 /**
700 * Returns the {@code double} value of this {@code Double} object.
701 *
702 * @return the {@code double} value represented by this object
703 */
704 public double doubleValue() {
705 return (double)value;
706 }
707
708 /**
709 * Returns a hash code for this {@code Double} object. The
710 * result is the exclusive OR of the two halves of the
711 * {@code long} integer bit representation, exactly as
712 * produced by the method {@link #doubleToLongBits(double)}, of
713 * the primitive {@code double} value represented by this
714 * {@code Double} object. That is, the hash code is the value
715 * of the expression:
716 *
717 * <blockquote>
718 * {@code (int)(v^(v>>>32))}
719 * </blockquote>
720 *
|