Our own implementation of Math.round due to difference between java 1.6 and 1.7 implementations See Java bug 6430675 Using java 1.6 implementation of Math.round defined as floor of 0.5d plus value. - Java java.lang

Java examples for java.lang:Math Value

Description

Our own implementation of Math.round due to difference between java 1.6 and 1.7 implementations See Java bug 6430675 Using java 1.6 implementation of Math.round defined as floor of 0.5d plus value.

Demo Code

/*//from   w  w  w .j  av a 2 s  . co  m
 * Copyright (c) 2014. Real Time Genomics Limited.
 *
 * Use of this source code is bound by the Real Time Genomics Limited Software Licence Agreement
 * for Academic Non-commercial Research Purposes only.
 *
 * If you did not receive a license accompanying this file, a copy must first be obtained by email
 * from support@realtimegenomics.com.  On downloading, using and/or continuing to use this source
 * code you accept the terms of that license agreement and any amendments to those terms that may
 * be made from time to time by Real Time Genomics Limited.
 */
//package com.java2s;

public class Main {
    /**
     * Our own implementation of Math.round due to difference between java 1.6 and 1.7 implementations
     * See <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6430675">Java bug 6430675</a>
     *
     * Using java 1.6 implementation of Math.round
     * defined as floor of 0.5d plus value.
     * @param val value to round
     * @return rounded value
     */
    public static long round(double val) {
        return (long) Math.floor(val + 0.5d);
    }
}

Related Tutorials