|
MDi JLib 1.7.4 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.microdeveloper.common.Num
public class Num
Provides methods for number manipulation.
Copyright©2007 MicroDeveloper, Inc.
Constructor Summary | |
---|---|
Num()
|
Method Summary | |
---|---|
static int |
byteToPositiveInt(byte b)
Convert a possibly negative valued byte to a positive value integer. |
static double |
decimalDegrees(String text)
Pass in a string that represents some form of lat or long and a decimal value is returned. |
static int |
endian(int x)
Reverse the byte order of a four byte integer. |
static short |
endian(short x)
Swap the upper and lower bytes of a two byte integer. |
static boolean |
inRange(char x,
char min,
char max)
A convenience method to test if a character is within a particular range. |
static boolean |
inRange(double x,
double min,
double max)
A convenience method to test if a double is within a particular range. |
static boolean |
inRange(int x,
int min,
int max)
A convenience method to test if an integer is within a particular range. |
static byte |
positiveIntToByte(int i)
Convert an integer possibly negative valued byte to a positive value integer. |
static double |
round(double value,
int decimalPlace)
Simple rounding function - why doesn't Java do this? |
static int[] |
toIntArray(Set values)
Each value will be cast to Integer and the values will be stored in an array. |
static Set |
toSet(int[] values)
Each int in the array is encapsulated in an Integer object and added to the set. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Num()
Method Detail |
---|
public static short endian(short x)
This is useful when you need to convert between Intel formatted integers(little endian) and Java/Motorola formatted integers(big endian).
x
- The number to be converted.
public static int endian(int x)
This is useful when you need to convert between Intel formatted integers(little endian) and Java/Motorola formatted integers(big endian).
If the original hex number was ABCD, the new hex number will be DCBA.
x
- The number to be converted.
public static int byteToPositiveInt(byte b)
A Java byte has a value of -128 to 127. With eight bits and no sign, the negative numbers could be represented as a value of 128 to 255. This method makes such a conversion, but stores the result in an integer since Java does not support unsigned bytes.
b
- The byte with a possibly negative value.
public static byte positiveIntToByte(int i)
A Java byte has a value of -128 to 127. With eight bits and no sign, the negative numbers could be represented as a value of 128 to 255. This method makes the conversion from 0-255 to -128-127.
This method assumes your integer will be of the range of 0 to 255. Using a value outside of this range could generate an exception.
i
- The integer in the range of 0 to 255.
public static boolean inRange(int x, int min, int max)
x
- The value to test. min
- The minimum value for x. max
- The maximum value for x.
public static boolean inRange(double x, double min, double max)
x
- The value to test. min
- The minimum value for x. max
- The maximum value for x.
public static boolean inRange(char x, char min, char max)
x
- The character to test. min
- The minimum value for x. max
- The maximum value for x.
public static double decimalDegrees(String text)
public static Set toSet(int[] values)
public static int[] toIntArray(Set values)
public static double round(double value, int decimalPlace)
|
MDi JLib 1.7.4 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |