diff options
author | fengzeng <fengzeng@multicorewareinc.com> | 2013-12-17 17:08:20 +0800 |
---|---|---|
committer | I-Jui (Ray) Sung <ray@multicorewareinc.com> | 2013-12-19 17:54:05 -0600 |
commit | 2013375890bf75f1b5dea529bd011880c7402ea6 (patch) | |
tree | 6f5649f52d3607cc01ecb690ce35ad8dcbad9679 /sc | |
parent | 774b8342ac15cdb06e9069cfac19c982ec6ca79e (diff) |
GPU Calc: Fix bug of TRUNC
AMLOEXT-365
Change-Id: I968ca9cc202706698a3fc5e957c4941c234779f7
Signed-off-by: haochen <haochen@multicorewareinc.com>
Signed-off-by: Wei Wei <weiwei@multicorewareinc.com>
Signed-off-by: I-Jui (Ray) Sung <ray@multicorewareinc.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/opencl/op_math.cxx | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/sc/source/core/opencl/op_math.cxx b/sc/source/core/opencl/op_math.cxx index 9e676a4f7447..d27476de29c0 100644 --- a/sc/source/core/opencl/op_math.cxx +++ b/sc/source/core/opencl/op_math.cxx @@ -1974,13 +1974,16 @@ void OpTrunc::GenSlidingWindowFunction(std::stringstream &ss, ss << ";\n"; } } + ss << " double argm = arg[0];\n"; ss << " int n = (int)arg[1];\n"; - ss << " int nn = 1;\n"; - ss << " for(int i=0; i<n; ++i)\n"; - ss << " nn *= 10;\n"; - ss << " n = (int)(arg[0] * nn);\n"; - ss << " arg[0] = (double)n / nn;\n"; - ss << " return arg[0];\n"; + ss << " double nn = 1.0f;\n"; + ss << " for(int i = 0; i < n; ++i)\n"; + ss << " {\n"; + ss << " argm = argm * 10;\n"; + ss << " nn = nn * 10;\n"; + ss << " }\n"; + ss << " modf(argm, &argm);\n"; + ss << " return argm / nn;\n"; ss << "}"; } void OpFloor::GenSlidingWindowFunction( |