public class NumberHelper
extends java.lang.Object
| Constructor and Description |
|---|
NumberHelper() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
isNumeric(java.lang.String s)
Checks if a given string contains a number
|
static double |
roundToSignificantFigures(double num,
int n)
Rounds number num to n significant figures.
|
static java.lang.Number |
toPrimitiveNumber(java.lang.String s)
Converts a string into its "closest" primitive type.
|
public static double roundToSignificantFigures(double num,
int n)
num - The numbern - The number of significant figurespublic static boolean isNumeric(java.lang.String s)
s - The stringpublic static java.lang.Number toPrimitiveNumber(java.lang.String s)
int. Otherwise, if it parses as a float, the number
returned will be a float. In all other cases, the
returned value is null.s - The string to convert into a numberCopyright © Sylvain HallĂ©. All Rights Reserved.