Example usage for java.lang Double valueOf

List of usage examples for java.lang Double valueOf

Introduction

In this page you can find the example usage for java.lang Double valueOf.

Prototype

@HotSpotIntrinsicCandidate
public static Double valueOf(double d) 

Source Link

Document

Returns a Double instance representing the specified double value.

Usage

From source file:com.act.lcms.v2.TraceIndexExtractor.java

public static void main(String[] args) throws Exception {
    Options opts = new Options();
    for (Option.Builder b : OPTION_BUILDERS) {
        opts.addOption(b.build());//www. ja v  a 2  s. c  o m
    }

    CommandLine cl = null;
    try {
        CommandLineParser parser = new DefaultParser();
        cl = parser.parse(opts, args);
    } catch (ParseException e) {
        System.err.format("Argument parsing failed: %s\n", e.getMessage());
        HELP_FORMATTER.printHelp(TraceIndexExtractor.class.getCanonicalName(), HELP_MESSAGE, opts, null, true);
        System.exit(1);
    }

    if (cl.hasOption("help")) {
        HELP_FORMATTER.printHelp(TraceIndexExtractor.class.getCanonicalName(), HELP_MESSAGE, opts, null, true);
        return;
    }

    // Not enough memory available?  We're gonna need a bigger heap.
    long maxMemory = Runtime.getRuntime().maxMemory();
    if (maxMemory < 1 << 34) { // 16GB
        String msg = StringUtils.join(
                String.format(
                        "You have run this class with a maximum heap size of less than 16GB (%d to be exact). ",
                        maxMemory),
                "There is no way this process will complete with that much space available. ",
                "Crank up your heap allocation with -Xmx and try again.", "");
        throw new RuntimeException(msg);
    }

    File inputFile = new File(cl.getOptionValue(OPTION_SCAN_FILE));
    if (!inputFile.exists()) {
        System.err.format("Cannot find input scan file at %s\n", inputFile.getAbsolutePath());
        HELP_FORMATTER.printHelp(TraceIndexExtractor.class.getCanonicalName(), HELP_MESSAGE, opts, null, true);
        System.exit(1);
    }

    File rocksDBFile = new File(cl.getOptionValue(OPTION_INDEX_PATH));
    if (rocksDBFile.exists()) {
        System.err.format("Index file at %s already exists--remove and retry\n", rocksDBFile.getAbsolutePath());
        HELP_FORMATTER.printHelp(TraceIndexExtractor.class.getCanonicalName(), HELP_MESSAGE, opts, null, true);
        System.exit(1);
    }

    List<Double> targetMZs = new ArrayList<>();
    try (BufferedReader reader = new BufferedReader(new FileReader(cl.getOptionValue(OPTION_TARGET_MASSES)))) {
        String line;
        while ((line = reader.readLine()) != null) {
            targetMZs.add(Double.valueOf(line));
        }
    }

    TraceIndexExtractor extractor = new TraceIndexExtractor();
    extractor.processScan(targetMZs, inputFile, rocksDBFile);
}

From source file:Main.java

public static Double increaseScore(Double score) {
    score = score.valueOf(score.doubleValue() + 1);
    return score;
}

From source file:Main.java

public static int getStopY(float angle, int distance) {
    return Double.valueOf(Math.rint(-1 * distance * Math.sin(Math.toRadians(angle)))).intValue();
}

From source file:Main.java

public static double getDouble(String text) {
    try {//from   ww  w.  ja  va 2  s. c  o m
        return Double.valueOf(text);
    } catch (Exception e) {

    }
    return 0;
}

From source file:Main.java

public static boolean isNumber(String n) {
    try {/*www .ja v  a 2 s . c  o  m*/
        double d = Double.valueOf(n).doubleValue();
        return true;
    } catch (NumberFormatException e) {
        e.printStackTrace();
        return false;
    }
}

From source file:Main.java

public static double roundOff(double amount) {
    return Double.valueOf(new DecimalFormat("0.00").format(amount));
}

From source file:Main.java

public static double doubleFromString(String s) {
    try {//from w  w  w .  jav a  2s . c  o m
        double val = Double.valueOf(s.toString().replace(",", ""));
        return val;
    } catch (NumberFormatException e) {

    }
    return 0;
}

From source file:Main.java

public static Double quotient(Double d1, Double d2) {
    if (d1 == null)
        return Double.valueOf(0);
    if (d2 == null)
        return Double.NaN;
    return d1 / d2;
}

From source file:Main.java

public static String getDecimal(String str) {
    double d = Double.valueOf(str);
    DecimalFormat df = new DecimalFormat("0.00");
    return df.format(d);
}

From source file:Main.java

public static Double percent(Double d1, Double d2) {
    if (d1 == null || d2 == null)
        return Double.valueOf(0);
    return d1 * (d2 / 100);
}