```{index} single: set_datatype (PDL) ``` ```{index} single: PDL::set_datatype ``` # set_datatype Change the element type of an ndarray in place. $pdl->set_datatype($typecode); `$typecode` is the integer type code, as `get_datatype` and a type's `enum` return; it must be in range or the call croaks with `set_datatype: datatype out of range`. A null ndarray that has no data yet simply takes on the new type. Otherwise the existing values are converted, exactly as `convert` would, but the ndarray itself is modified rather than a new one returned. `PDL::IO::Storable` uses this when reconstituting an ndarray it has read back.