Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 14 for IsNan (0.33 sec)

  1. src/cmp/cmp.go

    func Less[T Ordered](x, y T) bool {
    	return (isNaN(x) && !isNaN(y)) || x < y
    }
    
    // Compare returns
    //
    //	-1 if x is less than y,
    //	 0 if x equals y,
    //	+1 if x is greater than y.
    //
    // For floating-point types, a NaN is considered less than any non-NaN,
    // a NaN is considered equal to a NaN, and -0.0 is equal to 0.0.
    func Compare[T Ordered](x, y T) int {
    	xNaN := isNaN(x)
    	yNaN := isNaN(y)
    	if xNaN {
    		if yNaN {
    			return 0
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Fri Apr 19 16:31:02 UTC 2024
    - 2K bytes
    - Viewed (0)
  2. src/math/hypot.go

    		return archHypot(p, q)
    	}
    	return hypot(p, q)
    }
    
    func hypot(p, q float64) float64 {
    	p, q = Abs(p), Abs(q)
    	// special cases
    	switch {
    	case IsInf(p, 1) || IsInf(q, 1):
    		return Inf(1)
    	case IsNaN(p) || IsNaN(q):
    		return NaN()
    	}
    	if p < q {
    		p, q = q, p
    	}
    	if p == 0 {
    		return 0
    	}
    	q = q / p
    	return p * Sqrt(1+q*q)
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Oct 19 11:59:09 UTC 2023
    - 850 bytes
    - Viewed (0)
  3. src/runtime/minmax_test.go

    			t.Errorf("min(%v, %v) = %v, want %v", tt.max, tt.min, z, tt.min)
    		}
    	}
    	for _, x := range all {
    		if z := min(nan, x); !math.IsNaN(z) {
    			t.Errorf("min(%v, %v) = %v, want %v", nan, x, z, nan)
    		}
    		if z := min(x, nan); !math.IsNaN(z) {
    			t.Errorf("min(%v, %v) = %v, want %v", nan, x, z, nan)
    		}
    	}
    }
    
    func TestMaxFloat(t *testing.T) {
    	for _, tt := range tests {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Fri Jan 26 01:41:50 UTC 2024
    - 3.6K bytes
    - Viewed (0)
  4. test/typeparam/graph.go

    func _SliceEqual[Elem comparable](s1, s2 []Elem) bool {
    	if len(s1) != len(s2) {
    		return false
    	}
    	for i, v1 := range s1 {
    		v2 := s2[i]
    		if v1 != v2 {
    			isNaN := func(f Elem) bool { return f != f }
    			if !isNaN(v1) || !isNaN(v2) {
    				return false
    			}
    		}
    	}
    	return true
    }
    
    // A Graph is a collection of nodes. A node may have an arbitrary number
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Mar 26 19:58:28 UTC 2024
    - 5.7K bytes
    - Viewed (0)
  5. src/slices/sort.go

    		} else {
    			j = h // preserves x[j] >= target
    		}
    	}
    	// i == j, x[i-1] < target, and x[j] (= x[i]) >= target  =>  answer is i.
    	return i, i < n && (x[i] == target || (isNaN(x[i]) && isNaN(target)))
    }
    
    // BinarySearchFunc works like [BinarySearch], but uses a custom comparison
    // function. The slice must be sorted in increasing order, where "increasing"
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Wed Feb 07 23:54:41 UTC 2024
    - 5.8K bytes
    - Viewed (0)
  6. src/math/ldexp.go

    	}
    	return ldexp(frac, exp)
    }
    
    func ldexp(frac float64, exp int) float64 {
    	// special cases
    	switch {
    	case frac == 0:
    		return frac // correctly return -0
    	case IsInf(frac, 0) || IsNaN(frac):
    		return frac
    	}
    	frac, e := normalize(frac)
    	exp += e
    	x := Float64bits(frac)
    	exp += int(x>>shift)&mask - bias
    	if exp < -1075 {
    		return Copysign(0, frac) // underflow
    	}
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Oct 19 11:59:09 UTC 2023
    - 1.1K bytes
    - Viewed (0)
  7. src/maps/maps_test.go

    func equal[T comparable](v1, v2 T) bool {
    	return v1 == v2
    }
    
    // equalNaN is like == except that all NaNs are equal.
    func equalNaN[T comparable](v1, v2 T) bool {
    	isNaN := func(f T) bool { return f != f }
    	return v1 == v2 || (isNaN(v1) && isNaN(v2))
    }
    
    // equalStr compares ints and strings.
    func equalIntStr(v1 int, v2 string) bool {
    	return strconv.Itoa(v1) == v2
    }
    
    func TestEqualFunc(t *testing.T) {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Dec 05 17:05:56 UTC 2023
    - 5.6K bytes
    - Viewed (0)
  8. src/math/exp.go

    		Log2e = 1.44269504088896338700e+00
    
    		Overflow  = 7.09782712893383973096e+02
    		Underflow = -7.45133219101941108420e+02
    		NearZero  = 1.0 / (1 << 28) // 2**-28
    	)
    
    	// special cases
    	switch {
    	case IsNaN(x) || IsInf(x, 1):
    		return x
    	case IsInf(x, -1):
    		return 0
    	case x > Overflow:
    		return Inf(1)
    	case x < Underflow:
    		return 0
    	case -NearZero < x && x < NearZero:
    		return 1 + x
    	}
    
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Oct 19 11:59:09 UTC 2023
    - 5.4K bytes
    - Viewed (0)
  9. src/math/cmplx/pow.go

    //
    //	Pow(0, ±0) returns 1+0i
    //	Pow(0, c) for real(c)<0 returns Inf+0i if imag(c) is zero, otherwise Inf+Inf i.
    func Pow(x, y complex128) complex128 {
    	if x == 0 { // Guaranteed also true for x == -0.
    		if IsNaN(y) {
    			return NaN()
    		}
    		r, i := real(y), imag(y)
    		switch {
    		case r == 0:
    			return 1
    		case r < 0:
    			if i == 0 {
    				return complex(math.Inf(1), 0)
    			}
    			return Inf()
    		case r > 0:
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Oct 19 11:59:09 UTC 2023
    - 2.3K bytes
    - Viewed (0)
  10. src/math/erfinv.go

    //
    // Special cases are:
    //
    //	Erfinv(1) = +Inf
    //	Erfinv(-1) = -Inf
    //	Erfinv(x) = NaN if x < -1 or x > 1
    //	Erfinv(NaN) = NaN
    func Erfinv(x float64) float64 {
    	// special cases
    	if IsNaN(x) || x <= -1 || x >= 1 {
    		if x == -1 || x == 1 {
    			return Inf(int(x))
    		}
    		return NaN()
    	}
    
    	sign := false
    	if x < 0 {
    		x = -x
    		sign = true
    	}
    
    	var ans float64
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Oct 19 11:59:09 UTC 2023
    - 3.4K bytes
    - Viewed (0)
Back to top