File: log10.inc

package info (click to toggle)
libclc 0.2.0%2Bgit20160907-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,540 kB
  • ctags: 968
  • sloc: lisp: 7,842; ansic: 1,787; python: 623; cpp: 74; makefile: 10; pascal: 7; sh: 1
file content (13 lines) | stat: -rw-r--r-- 445 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE log10(__CLC_GENTYPE val) {
  // log10(x) = log2(x) / log2(10)
  // 1 / log2(10) = 0.30102999566 = log10(2)
  // SP representation is 0.30103 (0x1.344136p-2)
  // DP representation is 0.301029995659999993762312442414(0x1.34413509E61D8p-2)
#if __CLC_FPSIZE == 32
  return log2(val) * 0x1.344136p-2f;
#elif __CLC_FPSIZE == 64
  return log2(val) * 0x1.34413509E61D8p-2;
#else
#error unknown _CLC_FPSIZE
#endif
}