char* convertDoubleToJsonField(char* name, double value, int fractionalPartLength) { char* fieldName = convertStringToJsonFieldName(name); char* fieldValue = convertDoubleToString(value, fractionalPartLength); char* field = stringConcat3(fieldName, ":", fieldValue); free(fieldName); free(fieldValue); return field; }
TestResult* convertDoubleToStringTest() { double x = -123.123; double fractionalPartLength = 2; char* expected = "-123.12"; char* actual = convertDoubleToString(x, fractionalPartLength); TestResult* r = malloc(sizeof(TestResult)); r -> testName = "convertDoubleToStringTest"; r -> passed = areStringsEqual(actual, expected); free(actual); return r; }
string Function::diffclock(clock_t clock1,clock_t clock2) { double diffticks=clock1-clock2; double diffms=(diffticks); return convertDoubleToString(diffms); }