Java Integer Convert To fromInt(int intValue)

Here you can find the source of fromInt(int intValue)

Description

Interpret an int as its binary form

License

LGPL

Parameter

Parameter Description
intValue The int to interpret to binary

Return

The binary

Declaration

public static byte[] fromInt(int intValue) 

Method Source Code

//package com.java2s;
/*/*w  w w  .ja  v a 2s .  com*/
 * Hibernate, Relational Persistence for Idiomatic Java
 *
 * License: GNU Lesser General Public License (LGPL), version 2.1 or later.
 * See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
 */

public class Main {
    /**
     * Interpret an int as its binary form
     *
     * @param intValue The int to interpret to binary
     *
     * @return The binary
     */
    public static byte[] fromInt(int intValue) {
        byte[] bytes = new byte[4];
        bytes[0] = (byte) (intValue >> 24);
        bytes[1] = (byte) ((intValue << 8) >> 24);
        bytes[2] = (byte) ((intValue << 16) >> 24);
        bytes[3] = (byte) ((intValue << 24) >> 24);
        return bytes;
    }
}

Related

  1. fromInt(final int value, final int length)
  2. fromInt(int i)
  3. fromint(int i)
  4. fromInt(int input)
  5. fromInt(int input)
  6. fromInt(int key)
  7. fromInt(int value)
  8. fromInt(int value)
  9. fromInt(int value)