MCPcopy Create free account
hub / github.com/AnswerDotAI/gpu.cpp / testRoundTrip

Function testRoundTrip

numeric_types/half.cpp:49–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47}
48
49void testRoundTrip(float value) {
50 // half h = halfFromFloat(value);
51 half h = half(value);
52 float result = static_cast<float>(h);
53 char message[1024];
54
55 if (isnan(value)) {
56 snprintf(message, sizeof(message), "NaN correctly round tripped");
57 printResult(isnan(result), message, value, result);
58 } else if (isinf(value)) {
59 snprintf(message, sizeof(message), "Infinity correctly round tripped");
60 printResult(isinf(result) &&
61 ((value > 0 && result > 0) || (value < 0 && result < 0)),
62 message, value, result);
63 } else {
64 snprintf(message, sizeof(message), "%.10f correctly round tripped", value);
65 printResult(approximatelyEqual(result, value, EPSILON), message, value,
66 result);
67 }
68}
69
70void testRoundTrip(uint16_t value) {
71 half h;

Callers 2

testContainersFunction · 0.85
mainFunction · 0.85

Calls 5

halfClass · 0.85
printResultFunction · 0.85
approximatelyEqualFunction · 0.85
halfToFloatFunction · 0.85
halfFromFloatFunction · 0.85

Tested by

no test coverage detected