Skip to content

Commit

Permalink
Use log10u from math.h
Browse files Browse the repository at this point in the history
  • Loading branch information
aviallon committed Jun 14, 2020
1 parent a6e584f commit a35754c
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/knightos/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,11 +353,7 @@ void draw_float(SCREEN* screen, unsigned char x, unsigned char y, float value){
integer_part = (unsigned int)value;
frac_part = ((value - (float)integer_part)*10000);

#define __log10u(x) ((x >= 10000000u) ? 7 : (x >= 1000000u) ? 6 : \
(x >= 100000u) ? 5 : (x >= 10000u) ? 4 : \
(x >= 1000u) ? 3 : (x >= 100u) ? 2 : (x >= 10u) ? 1u : 0u)

integer_part_len = (__log10u(integer_part)) + 1;
integer_part_len = (log10u(integer_part)) + 1;

if(sgn){
draw_char(screen, x, y, '-');
Expand Down

0 comments on commit a35754c

Please sign in to comment.