Next: Tables, Previous: Multi-threaded operations, Up: Common program behavior [Contents][Index]
At the lowest level, the computer stores everything in terms of 1
or
0
. For example, each program in Gnuastro, or each astronomical image
you take with the telescope is actually a string of millions of these zeros
and ones. The space required to keep a zero or one is the smallest unit of
storage, and is known as a bit. However, understanding and
manipulating this string of bits is extremely hard for most
people. Therefore, we define packages of these bits along with a standard
on how to interpret the bits in each package as a type.
The most basic standard for reading the bits is integer numbers
(\(..., -2, -1, 0, 1, 2, ...\), more bits will give larger
limits). The common integer types are 8, 16, 32, and 64 bits wide. For each
width, there are two standards for reading the bits: signed and unsigned
integers. In the former, negative numbers are allowed and in the latter,
they aren’t. The unsigned
types thus have larger positive limits
(one extra bit), but no negative value. When the context of your work
doesn’t involve negative numbers (for example counting, where negative is
not defined), it is best to use the unsigned
types. For full
numerical range of all integer types, see below.
Another standard of converting a given number of bits to numbers is the floating point standard, this standard can approximately store any real number with a given precision. There are two common floating point types: 32-bit and 64-bit, for single and double precision floating point numbers respectively. The former is sufficient for data with less than 8 significant decimal digits (most astronomical data), while the latter is good for less than 16 significant decimal digits. The representation of real numbers as bits is much more complex than integers. If you are interested, you can start with the Wikipedia article.
With the conversion operators in Gnuastro’s Arithmetic, you can change the
types of data to each other, which is necessary in some contexts. For
example the program/library, that you intend to feed the data into, only
accepts floating point values, but you have an integer image. Another
situation that conversion can be helpful is when you know that your data
only has values that fit within int8
or uint16
. However it is
currently formatted in the float64
type. Operations involving
floating point or larger integer types are significantly slower than
integer or smaller-width types respectively. In the latter case, it also
requires much more (by 8 or 4 times in the example above) storage space. So
when you confront such situations and want to store/archive/transfter the
data, it is best convert them to the most efficient type.
The short and long names for the recognized numeric data types in Gnuastro are listed below. Both short and long names can be used when you want to specify a type. For example, as a value to the common option --type (see Input/Output options), or in the information comment lines of Gnuastro text table format. The ranges listed below are inclusive.
u8
uint8
8-bit un-signed integers, range:
\([0\rm{\ to\ }2^8-1]\) or \([0\rm{\ to\ }255]\).
i8
int8
8-bit signed integers, range:
\([-2^7\rm{\ to\ }2^7-1]\) or \([-127\rm{\ to\ }127]\).
u16
uint16
16-bit un-signed integers, range:
\([0\rm{\ to\ }2^{16}-1]\) or \([0\rm{\ to\ }65535]\).
i16
int16
16-bit signed integers, range:
\([-2^{15}\rm{\ to\ }2^{15}-1]\) or
\([-32768\rm{\ to\ }32768]\).
u32
uint32
32-bit un-signed integers, range:
\([0\rm{\ to\ }2^{32}-1]\) or
\([0\rm{\ to\ }4294967295]\).
i32
int32
32-bit signed integers, range:
\([-2^{31}\rm{\ to\ }2^{31}-1]\) or
\([-2147483648\rm{\ to\ }2147483647]\).
u64
uint64
64-bit un-signed integers, range
\([0\rm{\ to\ }2^{64}-1]\) or
\([0\rm{\ to\ }18446744073709551615]\).
i64
int64
64-bit signed integers, range:
\([-2^{63}\rm{\ to\ }2^{63}-1]\) or
\([-9223372036854775808\rm{\ to\ }9223372036854775807]\).
f32
float32
32-bit (single-precision) floating point types. The maximum (minimum is its negative) possible value is \(3.402823\times10^{38}\). Single-precision floating points can accurately represent a floating point number up to \(\sim7.2\) significant decimals. Given the heavy noise in astronomical data, this is usually more than sufficient for storing results.
f64
float64
64-bit (double-precision) floating point types. The maximum (minimum is its
negative) possible value is \(\sim10^{308}\). Double-precision
floating points can accurately represent a floating point number
\(\sim15.9\) significant decimals. This is usually good for processing
(mixing) the data internally, for example a sum of single precision data
(and later storing the result as float32
).
Some file formats don’t recognize all types. Some file formats
don’t recognize all the types, for example the FITS standard (see
Fits) does not define |
Next: Tables, Previous: Multi-threaded operations, Up: Common program behavior [Contents][Index]
JavaScript license information
GNU Astronomy Utilities 0.4 manual, September 2017.