Last change
on this file since 367 was 352, checked in by coas-nagasima, 6 years ago |
arm向けASP3版ECNLを追加
|
-
Property svn:eol-style
set to
native
-
Property svn:mime-type
set to
text/x-csrc;charset=UTF-8
|
File size:
477 bytes
|
Rev | Line | |
---|
[352] | 1 | #include <math.h>
|
---|
| 2 | #include <stdint.h>
|
---|
| 3 |
|
---|
| 4 | float scalbnf(float x, int n)
|
---|
| 5 | {
|
---|
| 6 | union {float f; uint32_t i;} u;
|
---|
| 7 | float_t y = x;
|
---|
| 8 |
|
---|
| 9 | if (n > 127) {
|
---|
| 10 | y *= 0x1p127f;
|
---|
| 11 | n -= 127;
|
---|
| 12 | if (n > 127) {
|
---|
| 13 | y *= 0x1p127f;
|
---|
| 14 | n -= 127;
|
---|
| 15 | if (n > 127)
|
---|
| 16 | n = 127;
|
---|
| 17 | }
|
---|
| 18 | } else if (n < -126) {
|
---|
| 19 | y *= 0x1p-126f * 0x1p24f;
|
---|
| 20 | n += 126 - 24;
|
---|
| 21 | if (n < -126) {
|
---|
| 22 | y *= 0x1p-126f * 0x1p24f;
|
---|
| 23 | n += 126 - 24;
|
---|
| 24 | if (n < -126)
|
---|
| 25 | n = -126;
|
---|
| 26 | }
|
---|
| 27 | }
|
---|
| 28 | u.i = (uint32_t)(0x7f+n)<<23;
|
---|
| 29 | x = y * u.f;
|
---|
| 30 | return x;
|
---|
| 31 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.