MCPcopy Create free account
hub / github.com/SamuraiT/mecab-python3 / SWIG_CanCastAsInteger

Function SWIG_CanCastAsInteger

src/MeCab/MeCab_wrap.cpp:3798–3825  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3796
3797
3798SWIGINTERNINLINE int
3799SWIG_CanCastAsInteger(double *d, double min, double max) {
3800 double x = *d;
3801 if ((min <= x && x <= max)) {
3802 double fx = floor(x);
3803 double cx = ceil(x);
3804 double rd = ((x - fx) < 0.5) ? fx : cx; /* simple rint */
3805 if ((errno == EDOM) || (errno == ERANGE)) {
3806 errno = 0;
3807 } else {
3808 double summ, reps, diff;
3809 if (rd < x) {
3810 diff = x - rd;
3811 } else if (rd > x) {
3812 diff = rd - x;
3813 } else {
3814 return 1;
3815 }
3816 summ = rd + x;
3817 reps = diff/summ;
3818 if (reps < 8*DBL_EPSILON) {
3819 *d = rd;
3820 return 1;
3821 }
3822 }
3823 }
3824 return 0;
3825}
3826
3827
3828SWIGINTERN int

Callers 3

SWIG_AsVal_longFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected