Casting Between Data Types
You can cast or convert attribute values in SciDB from one data type to another. SciDB supports type conversions between numerical data types (for example, from int8 to int32 or int8 to double) as well as the conversion of numeric data types to non-numeric data types, such as string.
You can explicitly request attribute type conversions. For example, if you have an integer data type and want to use an operator only defined to accept double data type attributes, you can use the following conversion to derive an attribute of the correct type.
Create an array that contains an integer attribute by entering:
AFL% store(build(<a1:int32>[i=0:0],2),A); {i} a1 {0} 2
Convert the integer values to doubles:
AFL% store(apply(A, a2, double(a1)), B); {i} a1,a2 {0} 2,2
This generates a new attribute, a2, with data type double derived from a1:
AFL% show(B); {i} schema {0} 'B<a1:int32,a2:double>[i=0:0]'
You can also convert a numeric data type to string, which returns a UTF-8 encoded string:
AFL% apply(A, a2, string(a1)); {i} a1,a2 {0} 2,'2'
Remove the arrays:
AFL% remove(A); remove(B);