我尝试在 GLSL Vulkan 计算着色器中实现Alma College 的 Andrew Thall 所著的论文Extended-Precision Floating-Point Numbers for GPU Computation。我需要这个,因为我的一些设备不支持双精度。
我的问题出在 quickTwoSum 函数中
vec2 quickTwoSum( float a , float b) {
float s = a + b;
float t = s - a;
float e = b - t;
return vec2(s, e);
}
Run Code Online (Sandbox Code Playgroud)
例如
a = 114251.609
b = -0.00107500004
Run Code Online (Sandbox Code Playgroud)
然后发生这种情况
s = 114251.609 // this is correct because b is to small
t = -0.00107500004 // <= why? (s - a) …
Run Code Online (Sandbox Code Playgroud)