Example usage for java.lang Byte MIN_VALUE

List of usage examples for java.lang Byte MIN_VALUE

Introduction

In this page you can find the example usage for java.lang Byte MIN_VALUE.

Prototype

byte MIN_VALUE

To view the source code for java.lang Byte MIN_VALUE.

Click Source Link

Document

A constant holding the minimum value a byte can have, -27.

Usage

From source file:Main.java

public static void main(String[] args) {
    System.out.println(Byte.MIN_VALUE);
    System.out.println(Byte.MAX_VALUE);
}

From source file:Main.java

public static void main(String args[]) {
    System.out.println("Min value from Byte class:" + Byte.MIN_VALUE);
}

From source file:Main.java

public static void main(String[] args) {
    System.out.println("Byte.MIN = " + Byte.MIN_VALUE);
    System.out.println("Byte.MAX = " + Byte.MAX_VALUE);
    System.out.println("Short.MIN = " + Short.MIN_VALUE);
    System.out.println("Short.MAX = " + Short.MAX_VALUE);
    System.out.println("Integer.MIN = " + Integer.MIN_VALUE);
    System.out.println("Integer.MAX = " + Integer.MAX_VALUE);
    System.out.println("Long.MIN = " + Long.MIN_VALUE);
    System.out.println("Long.MAX = " + Long.MAX_VALUE);
    System.out.println("Float.MIN = " + Float.MIN_VALUE);
    System.out.println("Float.MAX = " + Float.MAX_VALUE);
    System.out.println("Double.MIN = " + Double.MIN_VALUE);
    System.out.println("Double.MAX = " + Double.MAX_VALUE);
}

From source file:Main.java

public static void main(String args[]) {

    System.out.println("Min byte value   = " + Byte.MIN_VALUE);
    System.out.println("Max byte value   = " + Byte.MAX_VALUE);
    System.out.println("Min short value  = " + Short.MIN_VALUE);
    System.out.println("Max short value  = " + Short.MAX_VALUE);
    System.out.println("Min int value    = " + Integer.MIN_VALUE);
    System.out.println("Max int value    = " + Integer.MAX_VALUE);
    System.out.println("Min float value  = " + Float.MIN_VALUE);
    System.out.println("Max float value  = " + Float.MAX_VALUE);
    System.out.println("Min double value = " + Double.MIN_VALUE);
    System.out.println("Max double value = " + Double.MAX_VALUE);
}

From source file:MinVariablesDemo.java

public static void main(String args[]) {

    // integers// w w  w .j  a v  a 2s  .  co  m
    byte smallestByte = Byte.MIN_VALUE;
    short smallestShort = Short.MIN_VALUE;
    int smallestInteger = Integer.MIN_VALUE;
    long smallestLong = Long.MIN_VALUE;

    // real numbers
    float smallestFloat = Float.MIN_VALUE;
    double smallestDouble = Double.MIN_VALUE;

    // display them all
    System.out.println("The smallest byte value is " + smallestByte);
    System.out.println("The smallest short value is " + smallestShort);
    System.out.println("The smallest integer value is " + smallestInteger);
    System.out.println("The smallest long value is " + smallestLong);

    System.out.println("The smallest float value is " + smallestFloat);
    System.out.println("The smallest double value is " + smallestDouble);
}

From source file:Main.java

public static short toShort(byte[] bytes) {
    return (short) (((-(short) Byte.MIN_VALUE + (short) bytes[0]) << 8) - (short) Byte.MIN_VALUE
            + (short) bytes[1]);
}

From source file:Main.java

public static byte intToByte(int i) {
    if (i < Byte.MAX_VALUE && i > Byte.MIN_VALUE) {
        return (byte) i;
    }//  w w  w.  j ava 2 s.c om
    return (byte) i;
}

From source file:Main.java

/**
 * Convert uint8 into char( we treat char as uint8)
 * //w ww. j  av a 2  s . co  m
 * @param uint8
 *            the unit8 to be converted
 * @return the byte of the unint8
 */
public static byte convertUint8toByte(char uint8) {
    if (uint8 > Byte.MAX_VALUE - Byte.MIN_VALUE) {
        throw new RuntimeException("Out of Boundary");
    }
    return (byte) uint8;
}

From source file:Main.java

/** Helper method - gets a named element's value as a <I>Byte</I>.
   @param pElement The parent <I>Element</I>.
   @param strName Name of the element./*from w ww .j  a  v a  2  s.c  om*/
   @return Value of the element.
 */
public static byte getElementByte(Element pElement, String strName)
        throws ClassCastException, NumberFormatException {
    int nReturn = getElementInt(pElement, strName);

    if (Integer.MIN_VALUE == nReturn)
        return Byte.MIN_VALUE;

    return (byte) nReturn;
}

From source file:Main.java

public static byte toByte(long l) {
    if (l < Byte.MIN_VALUE || l > Byte.MAX_VALUE)
        throw new ArithmeticException("Value (" + l + ") cannot fit into byte");
    return (byte) l;
}