[libshumate/wip/mlundblad/mult-conversion-fixes: 1/2] scale: Avoid overflowing float multiplication




commit 3adc2c40da9c0968f0b5f8da792bf8412649296f
Author: Marcus Lundblad <ml update uu se>
Date:   Fri Nov 12 23:21:00 2021 +0100

    scale: Avoid overflowing float multiplication
    
    Declare local variable m_per_pixels as double
    to avoid potential overflow when promoting the
    result when muliplying with a float value passing
    the result to "log" (double precision).

 shumate/shumate-scale.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
---
diff --git a/shumate/shumate-scale.c b/shumate/shumate-scale.c
index 75ddf9e..665c9bf 100644
--- a/shumate/shumate-scale.c
+++ b/shumate/shumate-scale.c
@@ -93,7 +93,7 @@ shumate_scale_compute_length (ShumateScale *self,
   float base;
   float factor;
   gboolean is_small_unit = TRUE;
-  float m_per_pixel;
+  double m_per_pixel;
 
   g_assert (SHUMATE_IS_SCALE (self));
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]