github.com/Schaudge/grailbase@v0.0.0-20240223061707-44c758a471c0/simd/float_generic.go (about) 1 // Copyright 2021 GRAIL, Inc. All rights reserved. 2 // Use of this source code is governed by the Apache-2.0 3 // license that can be found in the LICENSE file. 4 5 // +build !amd64 appengine 6 7 package simd 8 9 import ( 10 "math" 11 ) 12 13 // FindNaNOrInf64 returns the position of the first NaN/inf value if one is 14 // present, and -1 otherwise. 15 func FindNaNOrInf64(data []float64) int { 16 for i, x := range data { 17 // Extract the exponent bits, and check if they're all set: that (and only 18 // that) corresponds to NaN/inf. 19 if (math.Float64bits(x) & (0x7ff << 52)) == (0x7ff << 52) { 20 return i 21 } 22 } 23 return -1 24 }