如何检查float
WebGL 中的 a 是否是无限的?
这两个似乎都对我有用:
bool isinf(float n) {
// one is actually required, without it n > inf if n is infinite
// assuming n is infinite, using just inf = 1.0 / 0.0, results in n > inf
float one = 1.0;
float inf = one / 0.0;
return abs(n) == inf;
}
bool isinf2(float n) {
float small_inf = 1.0 / 0.0;
return abs(n) > small_inf;
}
有没有更标准的做法?