Skip to content

Commit

Permalink
Remove the math
Browse files Browse the repository at this point in the history
Signed-off-by: Sourav Moitra <[email protected]>
  • Loading branch information
xw19 committed Jan 2, 2025
1 parent bfc8fca commit 169c00b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 4 deletions.
4 changes: 1 addition & 3 deletions src/ocispec/json_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,7 @@ json_double_to_uint64 (double d, uint64_t *converted)
// Safely convert double to uint64_t by checking for potential overflows
if (d >= 4294967296.0) { // Check if value is greater than or equal to 2^32
// TODO: Better solution for converting double to uint64
char string[24];
sprintf(string, "%0.f", d);
*converted = strtoull(string, NULL, 10);
*converted = 18446744073709551615UL;
} else {
// Handle smaller values (less than 2^32)
*converted = (uint64_t) d;
Expand Down
1 change: 0 additions & 1 deletion src/ocispec/json_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <string.h>
#include <stdint.h>
#include <jansson.h>
#include <math.h>

#ifdef __cplusplus
extern "C" {
Expand Down

0 comments on commit 169c00b

Please sign in to comment.