org.elasticsearch.common
Class Numbers

java.lang.Object
  extended by org.elasticsearch.common.Numbers

public final class Numbers
extends Object

A set of utlities around numbers.


Method Summary
static double bytesToDouble(byte[] arr)
          Converts a byte array to double.
static float bytesToFloat(byte[] arr)
          Converts a byte array to float.
static int bytesToInt(byte[] arr)
          Converts a byte array to an int.
static long bytesToLong(byte[] arr)
          Converts a byte array to a long.
static short bytesToShort(byte[] arr)
          Converts a byte array to an short.
static byte[] doubleToBytes(double val)
          Converts a double to a byte array.
static byte[] floatToBytes(float val)
          Converts a float to a byte array.
static byte[] intToBytes(int val)
          Converts an int to a byte array.
static byte[] longToBytes(long val)
          Converts a long to a byte array.
static byte[] shortToBytes(int val)
          Converts an int to a byte array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

bytesToShort

public static short bytesToShort(byte[] arr)
Converts a byte array to an short.

Parameters:
arr - The byte array to convert to an short
Returns:
The int converted

bytesToInt

public static int bytesToInt(byte[] arr)
Converts a byte array to an int.

Parameters:
arr - The byte array to convert to an int
Returns:
The int converted

bytesToLong

public static long bytesToLong(byte[] arr)
Converts a byte array to a long.

Parameters:
arr - The byte array to convert to a long
Returns:
The long converter

bytesToFloat

public static float bytesToFloat(byte[] arr)
Converts a byte array to float.

Parameters:
arr - The byte array to convert to a float
Returns:
The float converted

bytesToDouble

public static double bytesToDouble(byte[] arr)
Converts a byte array to double.

Parameters:
arr - The byte array to convert to a double
Returns:
The double converted

intToBytes

public static byte[] intToBytes(int val)
Converts an int to a byte array.

Parameters:
val - The int to convert to a byte array
Returns:
The byte array converted

shortToBytes

public static byte[] shortToBytes(int val)
Converts an int to a byte array.

Parameters:
val - The int to convert to a byte array
Returns:
The byte array converted

longToBytes

public static byte[] longToBytes(long val)
Converts a long to a byte array.

Parameters:
val - The long to convert to a byte array
Returns:
The byte array converted

floatToBytes

public static byte[] floatToBytes(float val)
Converts a float to a byte array.

Parameters:
val - The float to convert to a byte array
Returns:
The byte array converted

doubleToBytes

public static byte[] doubleToBytes(double val)
Converts a double to a byte array.

Parameters:
val - The double to convert to a byte array
Returns:
The byte array converted


Copyright © 2009-2012. All Rights Reserved.