From b3b566ddc2de36873a127c7b4adb4cdeafffcb6f Mon Sep 17 00:00:00 2001 From: David Tschumperle Date: Fri, 8 Mar 2024 14:40:31 +0100 Subject: [PATCH 1/2] . --- CImg.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CImg.h b/CImg.h index 9e2cdf13..810df516 100644 --- a/CImg.h +++ b/CImg.h @@ -21302,7 +21302,7 @@ namespace cimg_library { catch(CImgException&) { _cimg_mp_return(0); } if (is_vector(arg1)) _cimg_mp_vector1_v(mp_isint,arg1); if (is_const_scalar(arg1)) - _cimg_mp_return((unsigned int)((double)(longT)mem[arg1]==mem[arg1])); + _cimg_mp_return((unsigned int)(std::modf(mem[arg1],&val)==0)); _cimg_mp_scalar1(mp_isint,arg1); } @@ -26241,7 +26241,8 @@ namespace cimg_library { } static double mp_isint(_cimg_math_parser& mp) { - return (double)((double)(longT)_mp_arg(2)==_mp_arg(2)); + double val; + return (double)(std::modf(_mp_arg(2),&val)==0); } static double mp_isfile(_cimg_math_parser& mp) { From 64e8a0cdbbb7fee53795b8ba102fd5571a946840 Mon Sep 17 00:00:00 2001 From: David Tschumperle Date: Fri, 8 Mar 2024 15:47:49 +0100 Subject: [PATCH 2/2] math_parser() : Function 'isint()' can be used to test positive/negative/non-zero integers. --- CImg.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/CImg.h b/CImg.h index 810df516..ac3d33e8 100644 --- a/CImg.h +++ b/CImg.h @@ -21301,8 +21301,10 @@ namespace cimg_library { try { arg1 = compile(ss6,se1,depth1,0,block_flags); } catch(CImgException&) { _cimg_mp_return(0); } if (is_vector(arg1)) _cimg_mp_vector1_v(mp_isint,arg1); - if (is_const_scalar(arg1)) - _cimg_mp_return((unsigned int)(std::modf(mem[arg1],&val)==0)); + if (is_const_scalar(arg1)) { + val = mem[arg1]; + _cimg_mp_return((unsigned int)(std::modf(mem[arg1],&val1)?0:(val==0) + 2*(val>0) + 4*(val<0))); + } _cimg_mp_scalar1(mp_isint,arg1); } @@ -26241,8 +26243,8 @@ namespace cimg_library { } static double mp_isint(_cimg_math_parser& mp) { - double val; - return (double)(std::modf(_mp_arg(2),&val)==0); + double val = _mp_arg(2), intpart; + return std::modf(val,&intpart)?0:(val==0) + 2*(val>0) + 4*(val<0); } static double mp_isfile(_cimg_math_parser& mp) {