22 #include "goby/util/sci.h" 28 bool double_cmp(
double a,
double b,
int precision)
33 int a_part = (a - a_whole) * pow(10.0, precision);
34 int b_part = (b - b_whole) * pow(10.0, precision);
36 return (a_whole == b_whole) && (a_part == b_part);
41 assert(ceil_log2(1023) == 10);
42 assert(ceil_log2(1024) == 10);
43 assert(ceil_log2(1025) == 11);
45 assert(ceil_log2(15) == 4);
46 assert(ceil_log2(16) == 4);
47 assert(ceil_log2(17) == 5);
49 assert(ceil_log2(328529398) == 29);
51 assert(unbiased_round(5.5, 0) == 6);
52 assert(unbiased_round(4.5, 0) == 4);
54 assert(double_cmp(unbiased_round(4.123, 2), 4.12, 2));
57 assert(double_cmp(unbiased_round(mackenzie_soundspeed(25, 35, 1000), 3), 1550.744, 3));
59 std::cout <<
"all tests passed" << std::endl;