double.c
904 Bytes
#include <quiz.h>
#include <assert.h>
QUIZ_CASE(double_arithmetic) {
assert((float)1.123456789101112 == 1.123456789101112f);
assert((double)1.12345f - 1.12345< 0.0000001);
assert(3.12+2.00001 - 5.12001 < 0.0000000001);
assert(1e106+1e104 - 1.01e106 < 0.0000000001);
assert(1e-106+1e-104 - 1.01e104 < 0.0000000001);
assert(3.12345678901234567890/2.0000000000000001 - 1.56172839450617276136 < 0.0000000001);
assert(1.09876e206/2.45678e207 - 0.04472358127304846180773 < 0.0000000001);
assert(3.12345678901234567890*2.0000000000000001 - 6.24691357802469167014 < 0.0000000001);
assert(1.09876e106*2.45678e107 - 2.6994115928e213 < 0.0000000001);
assert(-3.12345678901234567890+2.0000000000000001 == -1.1234567890123457);
assert(-1e36+1e34 + 9.9e35 < 0.0000000001);
assert(3.12345678901234567890-2.0000000000000001 == 1.1234567890123457);
assert(1e36-1e34 - 9.9e35 < 0.0000000001);
}