Last change
on this file since 403 was 337, checked in by coas-nagasima, 6 years ago |
ASP3版ECNLを追加
|
-
Property svn:eol-style
set to
native
-
Property svn:mime-type
set to
text/x-csrc;charset=UTF-8
|
File size:
616 bytes
|
Line | |
---|
1 | #include "libm.h"
|
---|
2 |
|
---|
3 | float nexttowardf(float x, long double y)
|
---|
4 | {
|
---|
5 | union {float f; uint32_t i;} ux = {x};
|
---|
6 | uint32_t e;
|
---|
7 |
|
---|
8 | if (isnan(x) || isnan(y))
|
---|
9 | return x + y;
|
---|
10 | if (x == y)
|
---|
11 | return y;
|
---|
12 | if (x == 0) {
|
---|
13 | ux.i = 1;
|
---|
14 | if (signbit(y))
|
---|
15 | ux.i |= 0x80000000;
|
---|
16 | } else if (x < y) {
|
---|
17 | if (signbit(x))
|
---|
18 | ux.i--;
|
---|
19 | else
|
---|
20 | ux.i++;
|
---|
21 | } else {
|
---|
22 | if (signbit(x))
|
---|
23 | ux.i++;
|
---|
24 | else
|
---|
25 | ux.i--;
|
---|
26 | }
|
---|
27 | e = ux.i & 0x7f800000;
|
---|
28 | /* raise overflow if ux.f is infinite and x is finite */
|
---|
29 | if (e == 0x7f800000)
|
---|
30 | FORCE_EVAL(x+x);
|
---|
31 | /* raise underflow if ux.f is subnormal or zero */
|
---|
32 | if (e == 0)
|
---|
33 | FORCE_EVAL(x*x + ux.f*ux.f);
|
---|
34 | return ux.f;
|
---|
35 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.