498 return ((long) x) & 0xffL;
499 }
500
501
502 /**
503 * The number of bits used to represent a {@code byte} value in two's
504 * complement binary form.
505 *
506 * @since 1.5
507 */
508 public static final int SIZE = 8;
509
510 /**
511 * The number of bytes used to represent a {@code byte} value in two's
512 * complement binary form.
513 *
514 * @since 1.8
515 */
516 public static final int BYTES = SIZE / Byte.SIZE;
517
518 /** use serialVersionUID from JDK 1.1. for interoperability */
519 private static final long serialVersionUID = -7183698231559129828L;
520 }
|
498 return ((long) x) & 0xffL;
499 }
500
501
502 /**
503 * The number of bits used to represent a {@code byte} value in two's
504 * complement binary form.
505 *
506 * @since 1.5
507 */
508 public static final int SIZE = 8;
509
510 /**
511 * The number of bytes used to represent a {@code byte} value in two's
512 * complement binary form.
513 *
514 * @since 1.8
515 */
516 public static final int BYTES = SIZE / Byte.SIZE;
517
518 /**
519 * Adds two {@code byte}s together as per the + operator.
520 * Suitable for conversion as a method reference to functional interfaces such
521 * as {@code BinaryOperator<Byte>}.
522 *
523 * @param a an argument.
524 * @param b another argument.
525 * @return the sum of {@code a} and {@code b}.
526 * @since 1.8
527 */
528 public static byte sum(byte a, byte b) {
529 return (byte) (a + b);
530 }
531
532 /**
533 * Returns the greater of two {@code byte} values.
534 * Suitable for conversion as a method reference to functional interfaces such
535 * as {@code BinaryOperator<Byte>}.
536 *
537 * @param a an argument.
538 * @param b another argument.
539 * @return the larger of {@code a} and {@code b}.
540 * @since 1.8
541 */
542 public static byte max(byte a, byte b) {
543 return (a >= b) ? a : b;
544 }
545
546 /**
547 * Returns the lesser of two {@code byte} values.
548 * Suitable for conversion as a method reference to functional interfaces such
549 * as {@code BinaryOperator<Byte>}.
550 *
551 * @param a an argument.
552 * @param b another argument.
553 * @return the lesser of {@code a} and {@code b}.
554 * @since 1.8
555 */
556 public static byte min(byte a, byte b) {
557 return (a <= b) ? a : b;
558 }
559
560 /** use serialVersionUID from JDK 1.1. for interoperability */
561 private static final long serialVersionUID = -7183698231559129828L;
562 }
|