From 60a21da8f0621417ff08e5d7e091906c1a217035 Mon Sep 17 00:00:00 2001 From: Krishna Vedala <7001608+kvedala@users.noreply.github.com> Date: Wed, 22 Jul 2020 13:38:04 -0400 Subject: [PATCH] interpret large numbers as specific types --- hash/hash_adler32.c | 8 ++++---- hash/hash_crc32.c | 8 ++++---- hash/hash_djb2.c | 8 ++++---- hash/hash_sdbm.c | 8 ++++---- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/hash/hash_adler32.c b/hash/hash_adler32.c index 58b618fc..3e3dd751 100644 --- a/hash/hash_adler32.c +++ b/hash/hash_adler32.c @@ -36,10 +36,10 @@ uint32_t adler32(const char* s) */ void test_adler32() { - assert(adler32("Hello World") == 403375133); - assert(adler32("Hello World!") == 474547262); - assert(adler32("Hello world") == 413860925); - assert(adler32("Hello world!") == 487130206); + assert(adler32("Hello World") == (const uint32_t)403375133); + assert(adler32("Hello World!") == (const uint32_t)474547262); + assert(adler32("Hello world") == (const uint32_t)413860925); + assert(adler32("Hello world!") == (const uint32_t)487130206); printf("Tests passed\n"); } diff --git a/hash/hash_crc32.c b/hash/hash_crc32.c index a27f9ee6..ebab97a1 100644 --- a/hash/hash_crc32.c +++ b/hash/hash_crc32.c @@ -38,10 +38,10 @@ uint32_t crc32(const char* s) */ void test_crc32() { - assert(crc32("Hello World") == 1243066710); - assert(crc32("Hello World!") == 472456355); - assert(crc32("Hello world") == 2346098258); - assert(crc32("Hello world!") == 461707669); + assert(crc32("Hello World") == (const uint32_t)1243066710); + assert(crc32("Hello World!") == (const uint32_t)472456355); + assert(crc32("Hello world") == (const uint32_t)2346098258); + assert(crc32("Hello world!") == (const uint32_t)461707669); // printf("%" PRIu32 "\n", crc32("Hello World")); // printf("%" PRIu32 "\n", crc32("Hello World!")); // printf("%" PRIu32 "\n", crc32("Hello world")); diff --git a/hash/hash_djb2.c b/hash/hash_djb2.c index c8b1f22a..a880685a 100644 --- a/hash/hash_djb2.c +++ b/hash/hash_djb2.c @@ -32,10 +32,10 @@ uint64_t djb2(const char* s) */ void test_djb2() { - assert(djb2("Hello World") == 13827776004929097857); - assert(djb2("Hello World!") == 13594750393630990530); - assert(djb2("Hello world") == 13827776004967047329); - assert(djb2("Hello world!") == 13594750394883323106); + assert(djb2("Hello World") == (const uint64_t)13827776004929097857); + assert(djb2("Hello World!") == (const uint64_t)13594750393630990530); + assert(djb2("Hello world") == (const uint64_t)13827776004967047329); + assert(djb2("Hello world!") == (const uint64_t)13594750394883323106); printf("Tests passed\n"); } diff --git a/hash/hash_sdbm.c b/hash/hash_sdbm.c index 6e836651..36042c50 100644 --- a/hash/hash_sdbm.c +++ b/hash/hash_sdbm.c @@ -32,10 +32,10 @@ uint64_t sdbm(const char* s) */ void test_sdbm() { - assert(sdbm("Hello World") == 12881824461405877380); - assert(sdbm("Hello World!") == 7903571203300273309); - assert(sdbm("Hello world") == 15154913742888948900); - assert(sdbm("Hello world!") == 15254999417003201661); + assert(sdbm("Hello World") == (const uint64_t)12881824461405877380); + assert(sdbm("Hello World!") == (const uint64_t)7903571203300273309); + assert(sdbm("Hello world") == (const uint64_t)15154913742888948900); + assert(sdbm("Hello world!") == (const uint64_t)15254999417003201661); printf("Tests passed\n"); }