summaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
authorrander <rander.wang@intel.com>2017-03-21 10:00:06 +0800
committerYang Rong <rong.r.yang@intel.com>2017-04-17 16:08:48 +0800
commit4b5a156c7248d3e29de284f1ad7e1672a522cd6e (patch)
treeba56864d24b26fcce928b42c08f4cbf5a5ec3fc3 /backend
parenta42e3051d5fe58aaea6abf987839f759bea9b6d4 (diff)
backend: add convert_double_rtn(ulong)
the same as convert_double_rtz for ulong Signed-off-by: rander <rander.wang@intel.com> Tested-by: Yang Rong <rong.r.yang@intel.com>
Diffstat (limited to 'backend')
-rwxr-xr-xbackend/src/libocl/script/ocl_convert.sh14
1 files changed, 13 insertions, 1 deletions
diff --git a/backend/src/libocl/script/ocl_convert.sh b/backend/src/libocl/script/ocl_convert.sh
index aa3ac6cc..4a1c8c73 100755
--- a/backend/src/libocl/script/ocl_convert.sh
+++ b/backend/src/libocl/script/ocl_convert.sh
@@ -1287,7 +1287,19 @@ OVERLOADABLE double convert_double_rtz(ulong x)
OVERLOADABLE double convert_double_rtn(ulong x)
{
- return 0;
+ long exp;
+ long ret, ma, tmp;
+ int msbOne = 64 -clz(x);
+ exp = msbOne + DF_EXP_BIAS - 1;
+ ret = (exp << 52);
+
+ int shift = abs(53 - msbOne);
+ tmp = ret | ((x << shift) &DF_MAN_MASK);
+ ret |= (x >> shift) &DF_MAN_MASK;
+ ret = (msbOne < 54) ? tmp:ret;
+ ret = (!msbOne) ? 0:ret;
+
+ return as_double(ret);
}
OVERLOADABLE double convert_double_rte(ulong x)