From 2133f3c1293a1323e7115f72e7042e8ac67ed25d Mon Sep 17 00:00:00 2001 From: pesekon2 Date: Thu, 11 Apr 2024 16:49:26 +0200 Subject: [PATCH 1/4] r.mapcalc: add data types info to manual --- raster/r.mapcalc/r.mapcalc.html | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/raster/r.mapcalc/r.mapcalc.html b/raster/r.mapcalc/r.mapcalc.html index d4a21508143..a00f24fb3c0 100644 --- a/raster/r.mapcalc/r.mapcalc.html +++ b/raster/r.mapcalc/r.mapcalc.html @@ -389,6 +389,32 @@

Functions

Note, that the row() and col() indexing starts with 1. +

Data types and their precision

+ +There are three data types that can be used within the mapcalc expression. They +are defined with certain precision and within certain value range. + +

+data type               precision and value range info
+-------------------------------------------------------------------------------
+ int                    a 32-bit integer with a range from -2,147,483,647 to
+                        +2,147,483,647. The value -2,147,483,648 is reserved
+                        for NODATA
+ float                  a 32-bit float (Float32) with a range from -3.4E38 to
+                        3.4E38. However, the integer precision can be only
+                        ensured between -16,777,216 and 16,777,216. If your
+                        raster overpasses this range, it is strongly suggested
+                        to use the type double instead
+ double                 a 64-bit float (Float64) with a range from -1.79E308 to
+                        1.79E308. It is 8 bytes, 15-17 digits precision
+ null                   NULL value. Refer to section "NULL support" lower
+
+ +Note that the value counter rotates when the value range is reached. E.g., if +your expression is a = int(2,147,483,648), you will get NULL value. +For expression a = int(2,147,483,649), you will reach the lowest value +possible instead, i.e. -2,147,483,647. +

Floating point values in the expression

Floating point numbers are allowed in the expression. A floating point From 9a54fff8a5893cbc2af632752390aad7e3b006a0 Mon Sep 17 00:00:00 2001 From: Ondrej Pesek Date: Thu, 11 Apr 2024 23:05:58 +0200 Subject: [PATCH 2/4] Apply suggestions from code review Suggestions by @veroandreo Co-authored-by: Veronica Andreo --- raster/r.mapcalc/r.mapcalc.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/raster/r.mapcalc/r.mapcalc.html b/raster/r.mapcalc/r.mapcalc.html index a00f24fb3c0..fc0b5157e0b 100644 --- a/raster/r.mapcalc/r.mapcalc.html +++ b/raster/r.mapcalc/r.mapcalc.html @@ -399,15 +399,15 @@

Data types and their precision

------------------------------------------------------------------------------- int a 32-bit integer with a range from -2,147,483,647 to +2,147,483,647. The value -2,147,483,648 is reserved - for NODATA + for NODATA. float a 32-bit float (Float32) with a range from -3.4E38 to 3.4E38. However, the integer precision can be only ensured between -16,777,216 and 16,777,216. If your raster overpasses this range, it is strongly suggested - to use the type double instead + to use the type double instead. double a 64-bit float (Float64) with a range from -1.79E308 to - 1.79E308. It is 8 bytes, 15-17 digits precision - null NULL value. Refer to section "NULL support" lower + 1.79E308. It is 8 bytes, 15-17 digits precision. + null NULL value. Refer to section "NULL support" below. Note that the value counter rotates when the value range is reached. E.g., if From 5ed517ccf039dcd077dcd6485b4d5d2623c64475 Mon Sep 17 00:00:00 2001 From: Ondrej Pesek Date: Thu, 11 Apr 2024 23:16:36 +0200 Subject: [PATCH 3/4] delete commas as thousand separators in new examples --- raster/r.mapcalc/r.mapcalc.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/raster/r.mapcalc/r.mapcalc.html b/raster/r.mapcalc/r.mapcalc.html index fc0b5157e0b..72b842e8676 100644 --- a/raster/r.mapcalc/r.mapcalc.html +++ b/raster/r.mapcalc/r.mapcalc.html @@ -411,9 +411,9 @@

Data types and their precision

Note that the value counter rotates when the value range is reached. E.g., if -your expression is a = int(2,147,483,648), you will get NULL value. -For expression a = int(2,147,483,649), you will reach the lowest value -possible instead, i.e. -2,147,483,647. +your expression is a = int(2147483648), you will get NULL value. +For expression a = int(2147483649), you will reach the lowest value +possible instead, i.e. -2147483647.

Floating point values in the expression

From 08aa852e55819081859724db9b5bd7b6249d1c59 Mon Sep 17 00:00:00 2001 From: Ondrej Pesek Date: Mon, 15 Apr 2024 11:49:20 +0200 Subject: [PATCH 4/4] r.mapcalc: update value ranges - architecture dependency, wording --- raster/r.mapcalc/r.mapcalc.html | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/raster/r.mapcalc/r.mapcalc.html b/raster/r.mapcalc/r.mapcalc.html index 72b842e8676..5089b78537a 100644 --- a/raster/r.mapcalc/r.mapcalc.html +++ b/raster/r.mapcalc/r.mapcalc.html @@ -392,7 +392,10 @@

Functions

Data types and their precision

There are three data types that can be used within the mapcalc expression. They -are defined with certain precision and within certain value range. +are defined with certain precision and within certain value range. The +following table reports precision and value range info on AMD64 (x86-64) +architectures compiled with GCC/CLANG. Note that although this setting is the +most frequent one, the ranges could differ for different architectures.

 data type               precision and value range info
@@ -410,10 +413,10 @@ 

Data types and their precision

null NULL value. Refer to section "NULL support" below.
-Note that the value counter rotates when the value range is reached. E.g., if -your expression is a = int(2147483648), you will get NULL value. -For expression a = int(2147483649), you will reach the lowest value -possible instead, i.e. -2147483647. +Note that the value counter wraps around when the value overflows its range. +E.g., if your expression is a = int(2147483648), you will get NULL +value. For expression a = int(2147483649), you will reach the lowest +value possible instead, i.e. -2147483647.

Floating point values in the expression