From 052175e4b190598141fbcc64641cd5ee4db3602d Mon Sep 17 00:00:00 2001
From: Cristy <urban-warrior@imagemagick.org>
Date: Thu, 10 Oct 2019 20:40:18 -0400
Subject: [PATCH] https://github.com/ImageMagick/ImageMagick/issues/1743

---
 magick/statistic.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/magick/statistic.c b/magick/statistic.c
index 2db7c858f..827d87fa6 100644
--- a/magick/statistic.c
+++ b/magick/statistic.c
@@ -230,6 +230,9 @@ static MagickRealType ApplyEvaluateOperator(RandomInfo *random_info,
   MagickRealType
     result;
 
+  register ssize_t
+    i;
+
   result=0.0;
   switch (op)
   {
@@ -299,7 +302,9 @@ static MagickRealType ApplyEvaluateOperator(RandomInfo *random_info,
     }
     case LeftShiftEvaluateOperator:
     {
-      result=(MagickRealType) ((ssize_t) pixel << (ssize_t) (value+0.5));
+      result=(double) pixel;
+      for (i=0; i < (ssize_t) value; i++)
+        result*=2.0;
       break;
     }
     case LogEvaluateOperator:
@@ -359,7 +364,9 @@ static MagickRealType ApplyEvaluateOperator(RandomInfo *random_info,
     }
     case RightShiftEvaluateOperator:
     {
-      result=(MagickRealType) ((ssize_t) pixel >> (ssize_t) (value+0.5));
+      result=(MagickRealType) pixel;
+      for (i=0; i < (ssize_t) value; i++)
+        result/=2.0;
       break;
     }
     case RootMeanSquareEvaluateOperator:
