parseComplex64

Parse a string representation of a 64-bit complex number.

Usage

var parseComplex64 = require( '@stdlib/complex/float32/parse' );

parseComplex64( str )

Parses a string representation of a 64-bit complex number.

var parseComplex64 = require( '@stdlib/complex/float32/parse' );
var real = require( '@stdlib/complex/float32/real' );
var imag = require( '@stdlib/complex/float32/imag' );

var str = '5 + 3i';

var z = parseComplex64( str );
// returns <Complex64>

var re = real( z );
// returns 5.0

var im = imag( z );
// returns 3.0

For details on the string format, see Complex64.

Examples

var parseComplex64 = require( '@stdlib/complex/float32/parse' );
var isComplex64 = require( '@stdlib/assert/is-complex64' );
var real = require( '@stdlib/complex/float32/real' );
var imag = require( '@stdlib/complex/float32/imag' );

var str = '1e3 - 2.75i';

var z = parseComplex64( str );
var bool = isComplex64( z );
// returns true

bool = ( real( z ) === 1e3 );
// returns true

bool = ( imag( z ) === -2.75 );
// returns true
Did you find this page helpful?