Here you can find the source of sum(double x, double y)
Parameter | Description |
---|---|
x | First double |
y | Second double |
Double.isNaN(x)? y: Double.isNaN(y)? x: x + y;
public static double sum(double x, double y)
//package com.java2s; //License from project: Apache License public class Main { /**//from w ww.ja v a2 s . co m * Calculates sum of two doubles, but treats NaNs as zeros. * * @param x First double * @param y Second double * @return Sum(x,y) calculated as <code>Double.isNaN(x)? y: Double.isNaN(y)? x: x + y;</code> */ public static double sum(double x, double y) { return Double.isNaN(x) ? y : Double.isNaN(y) ? x : x + y; } }