Util function to determine number of digits from an integer
[blender.git] / source / blender / editors / space_text / text_draw.c
index 70b5feac280b7fa6ff246a5fe9eb08ca39b272b1..4eb66811c7d05ae498e07c007e96f2a04b4c41e0 100644 (file)
@@ -594,7 +594,7 @@ static void text_update_drawcache(SpaceText *st, ARegion *ar)
                        drawcache->total_lines = 0;
 
                        if (st->showlinenrs)
-                               st->linenrs_tot = (int)floor(log10((float)nlines)) + 1;
+                               st->linenrs_tot = integer_digits_i(nlines);
 
                        while (line) {
                                if (drawcache->valid_head) { /* we're inside valid head lines */
@@ -628,7 +628,7 @@ static void text_update_drawcache(SpaceText *st, ARegion *ar)
                        nlines = BLI_listbase_count(&txt->lines);
 
                        if (st->showlinenrs)
-                               st->linenrs_tot = (int)floor(log10((float)nlines)) + 1;
+                               st->linenrs_tot = integer_digits_i(nlines);
                }
 
                drawcache->total_lines = nlines;