pappewaio / r-stats-c-streamer

0 stars 0 forks source link

simplify the tests for error as it right now makes it difficult to overview all functions #4

Open pappewaio opened 3 years ago

pappewaio commented 3 years ago
int operator_qnorm(char **arrayvals, int arraypositions[]) {
  //take out element 1 which should be the pvalue
  double prob = strtod(arrayvals[arraypositions[0]], NULL);
  if (errno != 0) {
    perror("[ERROR] Failed to parse floating point number");
    errno = 0;
    return 1;
  } else if (prob == 0.0) {
    fprintf(stderr, "[ERROR] Given line was not a floating point number: %s", arrayvals[arraypositions[0]]);
    return 1;
  }
  printf("%lf", qnorm(prob, 0.0, 1.0, 1, 0));
  return 0;
}