Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Data Type Abbreviation

Return the single letter abbreviation for an underlying array data type.

Usage

var dtypeChar = require( '@stdlib/ndarray/base/dtype-char' );

dtypeChar( dtype )

Returns the single letter character abbreviation for an underlying array data type.

var ch = dtypeChar( 'float64' );
// returns 'd'

ch = dtypeChar( 'generic' );
// returns 'x'

If provided an unknown or unsupported data type, the function returns null.

var ch = dtypeChar( 'foobar' );
// returns null

Examples

var dtypeChar = require( '@stdlib/ndarray/base/dtype-char' );

var dtypes;
var ch;
var i;

dtypes = [
    'float64',
    'float32',
    'int8',
    'uint8',
    'uint8c',
    'int16',
    'uint16',
    'int32',
    'uint32',
    'binary',
    'generic',
    'foobar'
];

for ( i = 0; i < dtypes.length; i++ ) {
    ch = dtypeChar( dtypes[ i ] );
    console.log( '%s => %s', dtypes[ i ], ch );
}