diff --git a/general/g.region/printwindow.c b/general/g.region/printwindow.c index 3a64b07a738..407855d9bb5 100644 --- a/general/g.region/printwindow.c +++ b/general/g.region/printwindow.c @@ -469,7 +469,7 @@ void print_window(struct Cell_head *window, int print_flag, int flat_flag) double convergence; if (G_projection() == PROJECTION_XY) - convergence = INFINITY; + convergence = 0. / 0.; else if (G_projection() == PROJECTION_LL) convergence = 0.0; else { diff --git a/lib/btree2/kdtree.c b/lib/btree2/kdtree.c index ec0d19e0abc..54a122033dc 100644 --- a/lib/btree2/kdtree.c +++ b/lib/btree2/kdtree.c @@ -531,7 +531,7 @@ int kdtree_knn(struct kdtree *t, double *c, int *uid, double *d, int k, if (skip) sn.uid = *skip; - maxdist = INFINITY; + maxdist = 1.0 / 0.0; found = 0; /* go down */ diff --git a/lib/raster3d/mask.c b/lib/raster3d/mask.c index 5d9e4014b47..33e5c3c44ee 100644 --- a/lib/raster3d/mask.c +++ b/lib/raster3d/mask.c @@ -304,12 +304,12 @@ void Rast3d_mask_tile(RASTER3D_Map *map, int tileIndex, void *tile, int type) for (dy = y; dy < rows; dy++) { for (dx = x; dx < cols; dx++) { RASTER3D_MASKNUM(map, dx, dy, dz, tile, type); - tile = (int*)tile + length; + tile += length; } - tile = (int*) + xLength; + tile += xLength; } - tile = (int*) + yLength; + tile += yLength; } } diff --git a/lib/vector/Vlib/box.c b/lib/vector/Vlib/box.c index 497e624498b..b68e00cdd8f 100644 --- a/lib/vector/Vlib/box.c +++ b/lib/vector/Vlib/box.c @@ -248,7 +248,7 @@ int Vect_get_line_box(const struct Map_info *Map, int line, Line = Plus->Line[line]; if (Line == NULL) { /* dead */ - Box->N = Box->S = Box->E = Box->W = Box->T = Box->B = INFINITY; + Box->N = Box->S = Box->E = Box->W = Box->T = Box->B = 0. / 0.; return 0; } @@ -313,7 +313,7 @@ int Vect_get_area_box(const struct Map_info *Map, int area, Area = Plus->Area[area]; if (Area == NULL) { /* dead */ - Box->N = Box->S = Box->E = Box->W = Box->T = Box->B = INFINITY; + Box->N = Box->S = Box->E = Box->W = Box->T = Box->B = 0. / 0.; return 0; } @@ -360,7 +360,7 @@ int Vect_get_isle_box(const struct Map_info *Map, int isle, Isle = Plus->Isle[isle]; if (Isle == NULL) { /* dead */ - Box->N = Box->S = Box->E = Box->W = Box->T = Box->B = INFINITY; + Box->N = Box->S = Box->E = Box->W = Box->T = Box->B = 0. / 0.; return 0; } diff --git a/raster/r.horizon/main.c b/raster/r.horizon/main.c index 3e1834bfd91..806dc51068a 100644 --- a/raster/r.horizon/main.c +++ b/raster/r.horizon/main.c @@ -746,7 +746,7 @@ double horizon_height(void) { double height; - tanh0 = -INFINITY; + tanh0 = -1.0 / 0.0; /* -inf */ length = 0; height = searching(); diff --git a/raster/r.in.bin/main.c b/raster/r.in.bin/main.c index 56bf05249b2..e5d457b8dc3 100644 --- a/raster/r.in.bin/main.c +++ b/raster/r.in.bin/main.c @@ -255,7 +255,7 @@ int main(int argc, char *argv[]) const char *outpre; char output[GNAME_MAX]; const char *title; - double null_val = INFINITY; + double null_val = 0.0 / 0.0; int is_fp; int is_signed; int bytes, hbytes; diff --git a/raster/r.in.lidar/info.c b/raster/r.in.lidar/info.c index 24ea3223805..e201774b716 100644 --- a/raster/r.in.lidar/info.c +++ b/raster/r.in.lidar/info.c @@ -12,7 +12,6 @@ */ #include -#include /* For INIFINITY */ #include #include @@ -98,7 +97,7 @@ int scan_bounds(LASReaderH LAS_reader, int shell_style, int extents, int update, first = TRUE; /* init to nan in case no points are found */ - min_x = max_x = min_y = max_y = min_z = max_z = INFINITY; + min_x = max_x = min_y = max_y = min_z = max_z = 0.0 / 0.0; G_verbose_message(_("Scanning data ...")); diff --git a/raster/r.in.lidar/point_binning.c b/raster/r.in.lidar/point_binning.c index 1148deaf5ae..97e942d19b7 100644 --- a/raster/r.in.lidar/point_binning.c +++ b/raster/r.in.lidar/point_binning.c @@ -434,7 +434,7 @@ void write_median(struct BinIndex *bin_index, void *raster_row, Rast_set_null_value(ptr, 1, rtype); else { /* one or more points in cell */ - head_id = Rast_get_c_value((CELL*)index_array + n_offset, CELL_TYPE); + head_id = Rast_get_c_value(index_array + n_offset, CELL_TYPE); node_id = head_id; n = 0; @@ -493,7 +493,7 @@ void write_percentile(struct BinIndex *bin_index, void *raster_row, CELL_TYPE)) /* no points in cell */ Rast_set_null_value(ptr, 1, rtype); else { - head_id = Rast_get_c_value((CELL*)index_array + n_offset, CELL_TYPE); + head_id = Rast_get_c_value(index_array + n_offset, CELL_TYPE); node_id = head_id; n = 0; @@ -548,7 +548,7 @@ void write_skewness(struct BinIndex *bin_index, void *raster_row, CELL_TYPE)) /* no points in cell */ Rast_set_null_value(ptr, 1, rtype); else { - head_id = Rast_get_c_value((CELL*)index_array + n_offset, CELL_TYPE); + head_id = Rast_get_c_value(index_array + n_offset, CELL_TYPE); node_id = head_id; n = 0; /* count */ @@ -605,7 +605,7 @@ void write_trimmean(struct BinIndex *bin_index, void *raster_row, CELL_TYPE)) /* no points in cell */ Rast_set_null_value(ptr, 1, rtype); else { - head_id = Rast_get_c_value((CELL*)index_array + n_offset, CELL_TYPE); + head_id = Rast_get_c_value(index_array + n_offset, CELL_TYPE); node_id = head_id; n = 0; @@ -697,9 +697,9 @@ void write_values(struct PointBinning *point_binning, for (col = 0; col < cols; col++) { size_t offset = ((size_t)row * cols + col) * Rast_cell_size(rtype); double min = - Rast_get_d_value((DCELL*)point_binning->min_array + offset, rtype); + Rast_get_d_value(point_binning->min_array + offset, rtype); double max = - Rast_get_d_value((DCELL*)point_binning->max_array + offset, rtype); + Rast_get_d_value(point_binning->max_array + offset, rtype); Rast_set_d_value(ptr, max - min, rtype); ptr = G_incr_void_ptr(ptr, Rast_cell_size(rtype)); } @@ -714,7 +714,7 @@ void write_values(struct PointBinning *point_binning, int n = Rast_get_c_value(point_binning->n_array + n_offset, CELL_TYPE); double sum = - Rast_get_d_value((DCELL*)point_binning->sum_array + offset, rtype); + Rast_get_d_value(point_binning->sum_array + offset, rtype); if (n == 0) Rast_set_null_value(ptr, 1, rtype); @@ -765,12 +765,12 @@ void write_values(struct PointBinning *point_binning, continue; double sum_x = - Rast_get_d_value((DCELL*)point_binning->x_array + offset, rtype); + Rast_get_d_value(point_binning->x_array + offset, rtype); double sum_y = - Rast_get_d_value((DCELL*)point_binning->y_array + offset, rtype); + Rast_get_d_value(point_binning->y_array + offset, rtype); /* TODO: we do this also in mean writing */ double sum_z = - Rast_get_d_value((DCELL*)point_binning->sum_array + offset, rtype); + Rast_get_d_value(point_binning->sum_array + offset, rtype); /* We are not writing any categories. They are not needed * and potentially it is too much trouble to do it and it is diff --git a/raster/r.li/r.li.padrange/padrange.c b/raster/r.li/r.li.padrange/padrange.c index cda1465853e..9bd255ddd43 100644 --- a/raster/r.li/r.li.padrange/padrange.c +++ b/raster/r.li/r.li.padrange/padrange.c @@ -309,8 +309,8 @@ int calculate(int fd, struct area_entry *ad, double *result) (((NS_DIST1 + NS_DIST2) / 2) / hd.rows); /* get min and max patch size */ - min = INFINITY; - max = -INFINITY; + min = 1.0 / 0.0; /* inf */ + max = -1.0 / 0.0; /* -inf */ for (old_pid = 1; old_pid <= pid; old_pid++) { if (pst[old_pid].count > 0) { area_p = cell_size_m * pst[old_pid].count / 10000; @@ -543,8 +543,8 @@ int calculateD(int fd, struct area_entry *ad, double *result) (((NS_DIST1 + NS_DIST2) / 2) / hd.rows); /* get min and max patch size */ - min = INFINITY; - max = -INFINITY; + min = 1.0 / 0.0; /* inf */ + max = -1.0 / 0.0; /* -inf */ for (old_pid = 1; old_pid <= pid; old_pid++) { if (pst[old_pid].count > 0) { area_p = cell_size_m * pst[old_pid].count / 10000; @@ -777,8 +777,8 @@ int calculateF(int fd, struct area_entry *ad, double *result) (((NS_DIST1 + NS_DIST2) / 2) / hd.rows); /* get min and max patch size */ - min = INFINITY; - max = -INFINITY; + min = 1.0 / 0.0; /* inf */ + max = -1.0 / 0.0; /* -inf */ for (old_pid = 1; old_pid <= pid; old_pid++) { if (pst[old_pid].count > 0) { area_p = cell_size_m * pst[old_pid].count / 10000; diff --git a/raster/r.out.gdal/main.c b/raster/r.out.gdal/main.c index b4b5a8de127..f647881b0cf 100644 --- a/raster/r.out.gdal/main.c +++ b/raster/r.out.gdal/main.c @@ -1047,11 +1047,11 @@ double set_default_nodata_value(GDALDataType datatype, double min, double max) case GDT_Float32: case GDT_CFloat32: - return INFINITY; + return 0.0 / 0.0; case GDT_Float64: case GDT_CFloat64: - return INFINITY; + return 0.0 / 0.0; default: return 0; diff --git a/raster/r.series.accumulate/main.c b/raster/r.series.accumulate/main.c index f4a531f6632..0cc6c38958a 100644 --- a/raster/r.series.accumulate/main.c +++ b/raster/r.series.accumulate/main.c @@ -171,8 +171,8 @@ int main(int argc, char *argv[]) if (G_parser(argc, argv)) exit(EXIT_FAILURE); - lo = INFINITY; - hi = INFINITY; + lo = -1.0 / 0.0; /* -inf */ + hi = 1.0 / 0.0; /* inf */ method = METHOD_GDD; if (G_strncasecmp(parm.method->answer, "gdd", 3) == 0) diff --git a/raster/r.univar/r.univar_main.c b/raster/r.univar/r.univar_main.c index 9ecf74f615f..3e351ad0a56 100644 --- a/raster/r.univar/r.univar_main.c +++ b/raster/r.univar/r.univar_main.c @@ -170,8 +170,8 @@ int main(int argc, char *argv[]) /* table field separator */ zone_info.sep = G_option_to_separator(param.separator); - zone_info.min = NAN; - zone_info.max = NAN; + zone_info.min = 0.0 / 0.0; /* set to nan as default */ + zone_info.max = 0.0 / 0.0; /* set to nan as default */ zone_info.n_zones = 0; fdz = NULL; diff --git a/raster/r.univar/r3.univar_main.c b/raster/r.univar/r3.univar_main.c index 41591bfec6b..b3efa170dd0 100644 --- a/raster/r.univar/r3.univar_main.c +++ b/raster/r.univar/r3.univar_main.c @@ -132,10 +132,10 @@ int main(int argc, char *argv[]) /* table field separator */ zone_info.sep = G_option_to_separator(param.separator); - dmin = NAN; - dmax = NAN; - zone_info.min = NAN; - zone_info.max = NAN; + dmin = 0.0 / 0.0; /* set to nan as default */ + dmax = 0.0 / 0.0; /* set to nan as default */ + zone_info.min = 0.0 / 0.0; /* set to nan as default */ + zone_info.max = 0.0 / 0.0; /* set to nan as default */ zone_info.n_zones = 0; /* open 3D zoning raster with default region */ diff --git a/raster/r.univar/stats.c b/raster/r.univar/stats.c index 01126ad022c..0451e370e2c 100644 --- a/raster/r.univar/stats.c +++ b/raster/r.univar/stats.c @@ -30,8 +30,8 @@ univar_stat *create_univar_stat_struct(int map_type, int n_perc) for (i = 0; i < n_zones; i++) { stats[i].sum = 0.0; stats[i].sumsq = 0.0; - stats[i].min = NAN; - stats[i].max = NAN; + stats[i].min = 0.0 / 0.0; /* set to nan as default */ + stats[i].max = 0.0 / 0.0; /* set to nan as default */ stats[i].n_perc = n_perc; if (n_perc > 0) stats[i].perc = (double *)G_malloc(n_perc * sizeof(double)); @@ -131,7 +131,7 @@ int print_stats(univar_stat *stats) var_coef = (stdev / mean) * 100.; /* perhaps stdev/fabs(mean) ? */ if (stats[z].n == 0) - stats[z].sum = stats[z].sum_abs = NAN; + stats[z].sum = stats[z].sum_abs = 0.0 / 0.0; sprintf(sum_str, "%.15g", stats[z].sum); G_trim_decimal(sum_str); @@ -190,9 +190,9 @@ int print_stats(univar_stat *stats) quartile_perc = (double *)G_calloc(stats[z].n_perc, sizeof(double)); if (stats[z].n == 0) { - quartile_25 = median = quartile_75 = NAN; + quartile_25 = median = quartile_75 = 0.0 / 0.0; for (i = 0; i < stats[z].n_perc; i++) - quartile_perc[i] = NAN; + quartile_perc[i] = 0.0 / 0.0; } else { for (i = 0; i < stats[z].n_perc; i++) { @@ -402,7 +402,7 @@ int print_stats_table(univar_stat *stats) var_coef = (stdev / mean) * 100.; /* perhaps stdev/fabs(mean) ? */ if (stats[z].n == 0) - stats[z].sum = stats[z].sum_abs = NAN; + stats[z].sum = stats[z].sum_abs = 0.0 / 0.0; if (zone_info.n_zones) { int z_cat = z + zone_info.min; @@ -450,9 +450,9 @@ int print_stats_table(univar_stat *stats) quartile_perc = (double *)G_calloc(stats[z].n_perc, sizeof(double)); if (stats[z].n == 0) { - quartile_25 = median = quartile_75 = NAN; + quartile_25 = median = quartile_75 = 0.0 / 0.0; for (i = 0; i < stats[z].n_perc; i++) - quartile_perc[i] = NAN; + quartile_perc[i] = 0.0 / 0.0; } else { for (i = 0; i < stats[z].n_perc; i++) { diff --git a/raster3d/r3.in.lidar/info.c b/raster3d/r3.in.lidar/info.c index ce3fba3ba08..49912030655 100644 --- a/raster3d/r3.in.lidar/info.c +++ b/raster3d/r3.in.lidar/info.c @@ -13,7 +13,6 @@ */ #include -#include #include @@ -101,7 +100,7 @@ int scan_bounds(LASReaderH LAS_reader, int shell_style, int extents, int update, first = TRUE; /* init to nan in case no points are found */ - min_x = max_x = min_y = max_y = min_z = max_z = INFINITY; + min_x = max_x = min_y = max_y = min_z = max_z = 0.0 / 0.0; G_verbose_message(_("Scanning data ...")); diff --git a/vector/v.cluster/main.c b/vector/v.cluster/main.c index c0d4325b798..a2b4e37b6e0 100644 --- a/vector/v.cluster/main.c +++ b/vector/v.cluster/main.c @@ -256,7 +256,7 @@ int main(int argc, char *argv[]) c[2] = 0.0; n = 0; sum = sumsq = 0; - min = NAN; + min = 1.0 / 0.0; max = 0; kd = G_malloc(minpnts * sizeof(double)); ki = G_malloc(minpnts * sizeof(int)); @@ -463,7 +463,7 @@ int main(int argc, char *argv[]) c[2] = 0.0; n = 0; sum = sumsq = 0; - min = NAN; + min = 1.0 / 0.0; max = 0; kd = G_malloc(minpnts * sizeof(double)); ki = G_malloc(minpnts * sizeof(int)); diff --git a/vector/v.distance/distance.c b/vector/v.distance/distance.c index 8537faaf691..3ceff4f9b05 100644 --- a/vector/v.distance/distance.c +++ b/vector/v.distance/distance.c @@ -11,7 +11,7 @@ int get_line_box(const struct line_pnts *Points, struct bound_box *box) int i; if (Points->n_points == 0) { - box->E = box->W = box->N = box->S = box->T = box->B = INFINITY; + box->E = box->W = box->N = box->S = box->T = box->B = 0.0 / 0.0; return 0; } diff --git a/vector/v.voronoi/skeleton.c b/vector/v.voronoi/skeleton.c index 96b19bdc709..ada3d356a8d 100644 --- a/vector/v.voronoi/skeleton.c +++ b/vector/v.voronoi/skeleton.c @@ -528,7 +528,7 @@ int tie_up(void) IPoints[i]); } - distmin = INFINITY; + distmin = 1. / 0.; /* +inf */ xmin = x; ymin = y;