From DavinciWiki
Jump to: navigation, search


Converts numeric values to integers, while preserving their relative scale

Arguments and Return Values

Arguments: a numeric array, the output integer type, and optionally the minimum and maximum values to use for the output data

Return Value: An integer array of the specified type


Syntax: tointeger(inputdata, integertype = VAL [, minval = VAL] [, maxval = VAL])

tointeger() converts numeric data to integer format, while preserving the scale of the input data. That is, if the input data is of type byte, and the output type is short, then values which were 0 in the input become -32768 in the output, values which were 255 in the input become 32767 in the output, and other values are scaled appropriately between them.

If the output should not occupy the full range of the destination data type, the minimum and maximum values can be specified using the optional minval and maxval parameters.

This function will also convert float and double input, with the assumption that such data occupies the range 0.0 - 1.0.


dv> d
4x1x1 array of float, bsq format [16 bytes]
0.5000000000    0.0000000000    0.7500000000    1.000000000

dv> tointeger(d, integertype = "byte")
4x1x1 array of byte, bsq format [4 bytes]
127     0       191     255

dv> tointeger(d, integertype = "short")
4x1x1 array of short, bsq format [8 bytes]
0       -32768  16383   32767

dv> i = tointeger(d, integertype = "int")
4x1x1 array of int, bsq format [16 bytes]
0       -2147483648     1073741824      2147483647

DavinciWiki Mini-Nav Bar


Contact Developers

  • davinci-dev [AT]

All other topics

  • See navigation on the left

Related Functions

Recent Library Changes

Created On: 07-16-2012
Modified On: 05-02-2013

Personal tools