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:
514 bytes
|
Line | |
---|
1 | #include <float.h>
|
---|
2 | #include <math.h>
|
---|
3 | #include <stdint.h>
|
---|
4 |
|
---|
5 | #if FLT_EVAL_METHOD==0
|
---|
6 | #define EPS FLT_EPSILON
|
---|
7 | #elif FLT_EVAL_METHOD==1
|
---|
8 | #define EPS DBL_EPSILON
|
---|
9 | #elif FLT_EVAL_METHOD==2
|
---|
10 | #define EPS LDBL_EPSILON
|
---|
11 | #endif
|
---|
12 | static const float_t toint = 1/EPS;
|
---|
13 |
|
---|
14 | float rintf(float x)
|
---|
15 | {
|
---|
16 | union {float f; uint32_t i;} u = {x};
|
---|
17 | int e = u.i>>23 & 0xff;
|
---|
18 | int s = u.i>>31;
|
---|
19 | float_t y;
|
---|
20 |
|
---|
21 | if (e >= 0x7f+23)
|
---|
22 | return x;
|
---|
23 | if (s)
|
---|
24 | y = x - toint + toint;
|
---|
25 | else
|
---|
26 | y = x + toint - toint;
|
---|
27 | if (y == 0)
|
---|
28 | return s ? -0.0f : 0.0f;
|
---|
29 | return y;
|
---|
30 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.