Skip to content

Commit

Permalink
EXODUS: Use different implementation that does not require math library
Browse files Browse the repository at this point in the history
  • Loading branch information
gdsjaar committed Aug 12, 2024
1 parent a8e4fd8 commit a22eb1c
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions packages/seacas/libraries/exodus/src/ex_field_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "exodusII.h" // for ex_err, etc
#include "exodusII_int.h" // for EX_FATAL, etc
#include <assert.h>
#include <math.h>
#define _GNU_SOURCE
#include <string.h>

Expand Down Expand Up @@ -43,13 +42,19 @@ static size_t my_strlcat(char *restrict dst, const char *restrict src, size_t ma
return dstlen + srclen;
}

static int number_width(const size_t number)
static int number_width(size_t number)
{
/* Could use `(int)floor(log10(number)) + 1`, but that requires math library... */
if (number == 0) {
return 1;
}
int width = (int)floor(log10(number)) + 1;
return width;
int count = 0;
// Iterate till n has digits remaining
while (number != 0) {
number /= 10;
++count;
}
return count;
}

static void verify_valid_component(int component, size_t cardinality, size_t suffix_size)
Expand Down

0 comments on commit a22eb1c

Please sign in to comment.