it.geosolutions.io.output
Class MathUtils

Object
  extended by MathUtils

public final class MathUtils
extends Object

A class that contains several static utility methods. A class that contains several static methods for converting multiple bytes into one float or integer.

Author:
Benjamin Stark, Simone Giannecchini

Constructor Summary
MathUtils()
           
 
Method Summary
static byte[] bitVector2ByteVector(int bitVector, int length)
          Convert an integer containing length bits into a vector of bytes.
static double exp2(double val)
          exp2.
static byte[] Float2IBM(double fVal)
          Converts a double to the standard IBM representation for a single precision real floating point number.
static byte frexpExp(double val)
          frexpExp, builds and gives the exponent base 2 for the floating point representation of a real number.
static double frexpMant(double val)
          frexpMant, builds and gives the mantissa base 2 for the floating point representation of a real number.
static double IBM2FLoat(int a, int b, int c, int d)
          Convert four bytes into a float value.
static int int2(int a, int b)
          Convert two bytes into a signed integer.
static int int3(int a, int b, int c)
          Convert three bytes into a signed integer.
static int int4(int a, int b, int c, int d)
          Convert four bytes into a signed integer.
static double log2(double val)
          log2.
static byte[] signedInt2Bytes(int val, int numBytes)
          signedInt2Bytes, converts a signed integer to a vector of bytes.
static int uint2(int a, int b)
          Convert two bytes into an unsigned integer.
static int uint3(int a, int b, int c)
          Convert three bytes into an unsigned integer.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MathUtils

public MathUtils()
Method Detail

int2

public static int int2(int a,
                       int b)
Convert two bytes into a signed integer. Convert two bytes into a signed integer.

Parameters:
a - higher byte
b - lower byte
Returns:
integer value

int3

public static int int3(int a,
                       int b,
                       int c)
Convert three bytes into a signed integer. Convert three bytes into a signed integer.

Parameters:
a - higher byte
b - middle part byte
c - lower byte
Returns:
integer value

int4

public static int int4(int a,
                       int b,
                       int c,
                       int d)
Convert four bytes into a signed integer. Convert four bytes into a signed integer.

Parameters:
a - highest byte
b - higher middle byte
c - lower middle byte
d - lowest byte
Returns:
integer value

uint2

public static int uint2(int a,
                        int b)
Convert two bytes into an unsigned integer. Convert two bytes into an unsigned integer.

Parameters:
a - higher byte
b - lower byte
Returns:
integer value

uint3

public static int uint3(int a,
                        int b,
                        int c)
Convert three bytes into an unsigned integer. Convert three bytes into an unsigned integer.

Parameters:
a - higher byte
b - middle byte
c - lower byte
Returns:
integer value

IBM2FLoat

public static double IBM2FLoat(int a,
                               int b,
                               int c,
                               int d)
Convert four bytes into a float value. Convert four bytes into a float value.

Parameters:
a - highest byte
b - higher byte
c - lower byte
d - lowest byte
Returns:
float value

Float2IBM

public static byte[] Float2IBM(double fVal)
Converts a double to the standard IBM representation for a single precision real floating point number. Converts a float to the standard IBM representation for a single precision real floating point number. This code is heavily based on code from gribw a c utility to encode grib files (see gribw(riter) )}. Many thanks to the author.


bitVector2ByteVector

public static byte[] bitVector2ByteVector(int bitVector,
                                          int length)
Convert an integer containing length bits into a vector of bytes. Convert an integer containing length bits into a vector of bytes. The most signifiant byte is returned firs. The last byte contains the less signifiant part of the bitvector.

Parameters:
bitVector - int The bit vector to convert.
length - int The number of bits in the vector.
Returns:
byte[] Byte vector.

log2

public static double log2(double val)
log2. log2.

Parameters:
aFloat - float

exp2

public static double exp2(double val)
exp2. exp2.

Parameters:
val - double

signedInt2Bytes

public static byte[] signedInt2Bytes(int val,
                                     int numBytes)
signedInt2Bytes, converts a signed integer to a vector of bytes. signedInt2Bytes, converts a signed integer to a vector of bytes.


frexpMant

public static double frexpMant(double val)
frexpMant, builds and gives the mantissa base 2 for the floating point representation of a real number. frexpMant, builds and gives the mantissa base 2 for the floating point representation of a real number.


frexpExp

public static byte frexpExp(double val)
frexpExp, builds and gives the exponent base 2 for the floating point representation of a real number. frexpExp, builds give the exponent base 2 for the floating point representation of a real number.



Copyright © 2006-2010 GeoSolutions. All Rights Reserved.