@stdlib/complex-base-parse
v0.1.1
Published
Parses a string representing a complex number into a complex like object.
Downloads
20
Readme
parse
Parses a string representing a complex number into a complex like object
{re: number, im: number}
.
Installation
npm install @stdlib/complex-base-parse
Usage
var parse = require( '@stdlib/complex-base-parse' );
parse( str )
Parses a string representing a complex number into a complex like object.
var parse = require( '@stdlib/complex-base-parse' );
var str = '5 + 3i';
var z = parse( str );
// returns <{re: 5, im: 3}>
Examples
var parse = require( '@stdlib/complex-base-parse' );
var str;
var z;
z = parse( '5 + 4i' );
// returns {'re' : 5, 'im' : 4}
z = parse( 'Infinity + 2.34i' );
// returns {'re' : Infinity, 'im' : 2.34}
z = parse( 'NaN + 4i' );
// returns {'re' : NaN, 'im' : 4}
z = parse( '45i55 + 5' );
// returns null
z = parse( '5 + 6 + 10e4i' );
// returns {'re' : 11, 'im' : 100000}
z = parse( {} );
// returns null
See Also
@stdlib/complex-float32/ctor
: 64-bit complex number.
Notice
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
Community
License
See LICENSE.
Copyright
Copyright © 2016-2024. The Stdlib Authors.