net.myrrix.common
Class LangUtils

java.lang.Object
  extended by net.myrrix.common.LangUtils

public final class LangUtils
extends Object

General utility methods related to the language, or primitves.

Author:
Sean Owen

Method Summary
static boolean isFinite(double d)
           
static boolean isFinite(float f)
           
static int mod(long l, int m)
          Computes l mod m, such that the result is always in [0,m-1], for any long value including negative values.
static double parseDouble(String s)
           
static float parseFloat(String s)
          Parses a float from a String as if by Float.valueOf(String), but disallows special values like Float.NaN, Float.POSITIVE_INFINITY and Float.NEGATIVE_INFINITY.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

parseFloat

public static float parseFloat(String s)
Parses a float from a String as if by Float.valueOf(String), but disallows special values like Float.NaN, Float.POSITIVE_INFINITY and Float.NEGATIVE_INFINITY.

Parameters:
s - String to parse
Returns:
floating-point value in the String
Throws:
IllegalArgumentException - if input does not parse as a floating-point value, or is infinite or Float.NaN
See Also:
parseDouble(String)

isFinite

public static boolean isFinite(float f)
Returns:
true if argument is not Float.NaN, Float.POSITIVE_INFINITY or Float.NEGATIVE_INFINITY

parseDouble

public static double parseDouble(String s)
See Also:
parseFloat(String)

isFinite

public static boolean isFinite(double d)
Returns:
true if argument is not Double.NaN, Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY

mod

public static int mod(long l,
                      int m)
Computes l mod m, such that the result is always in [0,m-1], for any long value including negative values.

Parameters:
l - long value
m - modulus
Returns:
l % m if l is nonnegative, (l % m) + m otherwise


Copyright © 2012. All Rights Reserved.