Java Double to Boolean doubleToBoolean(double value)

Here you can find the source of doubleToBoolean(double value)

Description

double To Boolean

License

Apache License

Declaration

public static boolean doubleToBoolean(double value) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static final double epsilon = .0001;

    public static boolean doubleToBoolean(double value) {
        if (Math.abs(1 - value) < epsilon) {
            return true;
        } else if (Math.abs(value) < epsilon) {
            return false;
        } else//  w  w w.ja v  a 2  s  . c  o  m
            throw new RuntimeException(
                    "Failed to convert to boolean, not near zero or one: "
                            + value);
    }
}

Related

  1. doubleToBoolean(double d)
  2. doubleToBoolean(double[] values)
  3. doubleToboolean(final double value)