MCPcopy Create free account
hub / github.com/apache/cloudberry / strtodouble

Function strtodouble

src/bin/pgbench/pgbench.c:883–905  ·  view source on GitHub ↗

convert string to double, detecting overflows/underflows */

Source from the content-addressed store, hash-verified

881
882/* convert string to double, detecting overflows/underflows */
883bool
884strtodouble(const char *str, bool errorOK, double *dv)
885{
886 char *end;
887
888 errno = 0;
889 *dv = strtod(str, &end);
890
891 if (unlikely(errno != 0))
892 {
893 if (!errorOK)
894 pg_log_error("value \"%s\" is out of range for type double", str);
895 return false;
896 }
897
898 if (unlikely(end == str || *end != '\0'))
899 {
900 if (!errorOK)
901 pg_log_error("invalid input syntax for type double: \"%s\"", str);
902 return false;
903 }
904 return true;
905}
906
907/*
908 * Initialize a random state struct.

Callers 1

makeVariableValueFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected