Engineering

Members

(static) erfcPrecise

See
  • erfc.precise

(static) erfPrecise

See
  • erf.precise

Methods

(inner) besselI(x, order) → {number}

Returns the modified Bessel function In(x).

Parameters:
NameTypeDescription
xnumber

The value at which to evaluate the function

ordernumber

The order of the Bessel function. If order is not an integer, it is truncated

See
Returns:

The calculated modified Bessel function for the given value of x and the specified order

Type: 
number
Example
rosettajs.besselI(2.6, 1) // returns 2.7553843378955585

(inner) besselJ(x, order) → {number}

Returns the Bessel function Jn(x).

Parameters:
NameTypeDescription
xnumber

The value at which to evaluate the function

ordernumber

The order of the Bessel function. If order is not an integer, it is truncated

See
Returns:

The calculated Bessel function for the given value of x and the specified order

Type: 
number
Example
rosettajs.besselJ(2.6, 1) // returns 0.47081826649775615

(inner) besselK(x, order) → {number}

Returns the modified Bessel function Kn(x).

Parameters:
NameTypeDescription
xnumber

The value at which to evaluate the function.

ordernumber

The order of the Bessel function. If order is not an integer, it is truncated

See
Returns:

The calculated Bessel function for the given value of x and the specified order

Type: 
number
Example
rosettajs.besselK(2.6, 1) // returns 0.0652840440474331

(inner) besselY(x, order) → {number}

Returns the Bessel function Yn(x).

Parameters:
NameTypeDescription
xnumber

The value at which to evaluate the function

ordernumber

The order of the function. If order is not an integer, it is truncated

See
Returns:

The calculated Bessel function for the given value of x and the specified order

Type: 
number
Example
rosettajs.besselY(2.6, 1) // returns 0.18836354378844533

(inner) bin2Dec(number) → {number}

Converts a binary number to decimal.

Parameters:
NameTypeDescription
numbernumber

The binary number you want to convert. Number cannot contain more than 10 characters (10 bits). The most significant bit of number is the sign bit. The remaining 9 bits are magnitude bits. Negative numbers are represented using two's-complement notation.

See
Returns:

A decimal for the given binary number

Type: 
number
Example
rosettajs.bin2Dec(1100001) // returns 97

(inner) bin2Hex(number, placesopt) → {string}

Converts a binary number to hexadecimal.

Parameters:
NameTypeAttributesDescription
numbernumber

The binary number you want to convert. Number cannot contain more than 10 characters (10 bits). The most significant bit of number is the sign bit. The remaining 9 bits are magnitude bits. Negative numbers are represented using two's-complement notation.

placesnumber<optional>

The number of characters to use. If places is omitted, bin2Hex uses the minimum number of characters necessary. Places is useful for padding the return value with leading 0s (zeros).

See
Returns:

A hexadecimal for the given binary number

Type: 
string
Examples
rosettajs.bin2Hex(11111011) // returns fb
rosettajs.bin2Hex(11111011, 4) // returns 00fb

(inner) bin2Oct(number, placesopt) → {string}

Converts a binary number to octal.

Parameters:
NameTypeAttributesDescription
numbernumber

The binary number you want to convert. Number cannot contain more than 10 characters (10 bits). The most significant bit of number is the sign bit. The remaining 9 bits are magnitude bits. Negative numbers are represented using two's-complement notation.

placesnumber<optional>

The number of characters to use. If places is omitted, bin2Oct uses the minimum number of characters necessary. Places is useful for padding the return value with leading 0s (zeros).

See
Returns:

A octal for the given binary number

Type: 
string
Examples
rosettajs.bin2Oct(1001) // returns 11
rosettajs.bin2Oct(1001, 4) // returns 0011

(inner) bitAnd(number1, number2) → {number}

Returns a bitwise 'AND' of two numbers.

Parameters:
NameTypeDescription
number1number

A decimal greater than or equal to 0

number2number

A decimal greater than or equal to 0

See
Returns:

A decimal that is a bitwise 'AND' of the 2 given numbers

Type: 
number
Example
rosettajs.bitAnd(7,29) // returns 5

(inner) bitLShift(number, shift) → {number}

Returns a value number shifted left by shift_amount bits.

Parameters:
NameTypeDescription
numbernumber

A integer greater than or equal to 0

shiftnumber

A integer indicating amount of bits to shift

See
Returns:

A decimal representing the specified number shifted left by specified amount of bits

Type: 
number
Example
rosettajs.bitLShift(5,3) // returns 40

(inner) bitOr(number1, number2) → {number}

Returns a bitwise 'OR' of two numbers.

Parameters:
NameTypeDescription
number1number

A decimal greater than or equal to 0

number2number

A decimal greater than or equal to 0

See
Returns:

A decimal that is a bitwise 'OR' of the 2 given numbers

Type: 
number
Example
rosettajs.bitOr(7,29) // returns 31

(inner) bitRShift(number, shift) → {number}

Returns a value number shifted right by shift_amount bits.

Parameters:
NameTypeDescription
numbernumber

A integer greater than or equal to 0

shiftnumber

A integer indicating amount of bits to shift

See
Returns:

A decimal representing the specified number shifted right by specified amount of bits

Type: 
number
Example
rosettajs.bitRShift(29,2) // returns 7

(inner) bitXOr(number1, number2) → {number}

Returns a bitwise 'XOR' of two numbers.

Parameters:
NameTypeDescription
number1number

A decimal greater than or equal to 0

number2number

A decimal greater than or equal to 0

See
Returns:

A decimal that is a bitwise 'XOR' of the 2 given numbers

Type: 
number
Example
rosettajs.bitXOr(7,29) // returns 26

(inner) complex(real, imaginary, suffixopt) → {string|number}

Converts real and imaginary coefficients into a complex number.

Parameters:
NameTypeAttributesDefaultDescription
realnumber

The real coefficient of the complex number

imaginarynumber

The imaginary coefficient of the complex number

suffixString<optional>
i

The suffix, either lowercase "i" or "j", for the imaginary component of the complex number. If omitted, suffix is assumed to be "i".

See
Returns:

A complex number from the given real and imaginary coefficient numbers

Type: 
string | number
Examples
rosettajs.complex(4,5) // returns 4+5i
rosettajs.complex(4,5,"j") // returns 4+5j

(inner) convert(number, from_unit, to_unit) → {number}

Converts a number from one measurement system to another.

Parameters:
NameTypeDescription
numbernumber

The value in from_units to convert

from_unitnumber

The units for number

to_unitnumber

The units for the result

See
Returns:

A number representing conversion from one measurement system to another

Type: 
number
Example
rosettajs.convert(1, "lbm", "kg") // returns 0.45359237

(inner) dec2Bin(number, placesopt) → {number}

Converts a decimal number to binary.

Parameters:
NameTypeAttributesDescription
numbernumber

The decimal integer you want to convert. If number is negative, valid place values are ignored and dec2Bin returns a 10-character (10-bit) binary number in which the most significant bit is the sign bit. The remaining 9 bits are magnitude bits. Negative numbers are represented using two's-complement notation.

placesnumber<optional>

The number of characters to use. If places is omitted, dec2Bin uses the minimum number of characters necessary. Places is useful for padding the return value with leading 0s (zeros).

See
Returns:

A binary for the given decimal number

Type: 
number
Examples
rosettajs.dec2Bin(10,5) // returns 01010
rosettajs.dec2Bin(-90) // returns 1110100110

(inner) dec2Hex(number, placesopt) → {string}

Converts a decimal number to hexadecimal.

Parameters:
NameTypeAttributesDescription
numbernumber

The decimal integer you want to convert. If number is negative, places is ignored and dec2Hex returns a 10-character (40-bit) hexadecimal number in which the most significant bit is the sign bit. The remaining 39 bits are magnitude bits. Negative numbers are represented using two's-complement notation.

placesnumber<optional>

The number of characters to use. If places is omitted, dec2Hex uses the minimum number of characters necessary. Places is useful for padding the return value with leading 0s (zeros).

See
Returns:

A hexadecimal for the given decimal number

Type: 
string
Examples
rosettajs.dec2Hex(90, 4) // returns 005a
rosettajs.dec2Hex(-75) // returns ffffffffb5

(inner) dec2Oct(number, placesopt) → {number}

Converts a decimal number to octal.

Parameters:
NameTypeAttributesDescription
numbernumber

The decimal integer you want to convert. If number is negative, places is ignored and dec2Oct returns a 10-character (30-bit) octal number in which the most significant bit is the sign bit. The remaining 29 bits are magnitude bits. Negative numbers are represented using two's-complement notation.

placesnumber<optional>

The number of characters to use. If places is omitted, dec2Oct uses the minimum number of characters necessary. Places is useful for padding the return value with leading 0s (zeros).

See
Returns:

A octal for the given decimal number

Type: 
number
Examples
rosettajs.dec2Oct(78, 3) // returns 116
rosettajs.dec2Oct(-75) // returns 7777777665

(inner) delta(number1, number2opt) → {number}

Tests whether two values are equal.

Parameters:
NameTypeAttributesDefaultDescription
number1number

The first number

number2number<optional>
0

The second number. If omitted, number2 is assumed to be zero.

See
Returns:

1 if number1 = number2; returns 0 otherwise

Type: 
number
Examples
rosettajs.delta(6, 4) // returns 0
rosettajs.delta(8, 8) // returns 1

(inner) erf(lower_bound, upper_boundopt) → {number}

Returns the error function integrated between lower_limit and upper_limit.

Parameters:
NameTypeAttributesDefaultDescription
lower_boundnumber

The lower bound for integrating ERF

upper_boundnumber<optional>
0

The upper bound for integrating ERF. If omitted, ERF integrates between zero and lower_limit.

See
Returns:

The error function integrated between lower_limit and upper_limit

Type: 
number
Example
rosettajs.erf(0.875) // returns 0.7840750610598597

(inner) erfc(x) → {number}

Returns the complementary error function.

Parameters:
NameTypeDescription
xnumber

The lower bound for integrating ERFC

See
Returns:

Complementary ERF of provided number

Type: 
number
Example
rosettajs.erfc(2) // returns 0.004677734981047288

(inner) geStep(number, stepopt) → {number}

Tests whether a number is greater than a threshold value.

Parameters:
NameTypeAttributesDefaultDescription
numbernumber

The value to test against step

stepnumber<optional>
0

The threshold value. If you omit a value for step, geStep uses zero.

See
Returns:

1 if number ≥ step; returns 0 (zero) otherwise.

Type: 
number
Examples
rosettajs.geStep(6) // returns 1
rosettajs.geStep(6,8) // returns 0

(inner) hex2Bin(number, placesopt) → {string}

Converts a hexadecimal number to binary.

Parameters:
NameTypeAttributesDescription
numberstring

The hexadecimal number you want to convert. Number cannot contain more than 10 characters. The most significant bit of number is the sign bit (40th bit from the right). The remaining 9 bits are magnitude bits. Negative numbers are represented using two's-complement notation.

placesnumber<optional>

The number of characters to use. If places is omitted, hex2Bin uses the minimum number of characters necessary. Places is useful for padding the return value with leading 0s (zeros).

See
Returns:

A binary for the given hexadecimal

Type: 
string
Examples
rosettajs.hex2Bin("B") // returns 1011
rosettajs.hex2Bin("B",10) // returns 0000001011

(inner) hex2Dec(number) → {number}

Converts a hexadecimal number to decimal.

Parameters:
NameTypeDescription
numberstring

The hexadecimal number you want to convert. Number cannot contain more than 10 characters (40 bits). The most significant bit of number is the sign bit. The remaining 39 bits are magnitude bits. Negative numbers are represented using two's-complement notation.

See
Returns:

A decimal for the given hexadecimal number

Type: 
number
Example
rosettajs.hex2Dec("A6") // returns 166

(inner) hex2Oct(number, placesopt) → {string}

Converts a hexadecimal number to octal

Parameters:
NameTypeAttributesDescription
numberstring

The hexadecimal number you want to convert. Number cannot contain more than 10 characters. The most significant bit of number is the sign bit. The remaining 39 bits are magnitude bits. Negative numbers are represented using two's-complement notation.

placesnumber<optional>

The number of characters to use. If places is omitted, hex2Oct uses the minimum number of characters necessary. Places is useful for padding the return value with leading 0s (zeros).

See
Returns:

A octal for the given hexadecimal number

Type: 
string
Examples
rosettajs.hex2Oct("B") // returns 13
rosettajs.hex2Oct("B",10) // 0000000013

(inner) imAbs(inumber) → {number}

Returns the absolute value (modulus) of a complex number.

Parameters:
NameTypeDescription
inumberstring | number

A complex number for which you want the absolute value

See
Returns:

Absolute value for the given complex number

Type: 
number
Example
rosettajs.imAbs("9+12i") // returns 15

(inner) imaginary(inumber) → {string|number}

Returns the imaginary coefficient of a complex number.

Parameters:
NameTypeDescription
inumberstring | number

A complex number for which you want the imaginary coefficient

See
Returns:

The imaginary coefficient of the given complex number

Type: 
string | number
Examples
rosettajs.imaginary("4+5i") // returns 5
rosettajs.imaginary(7) // returns 0

(inner) imArgument(inumber) → {string|number}

Returns the argument theta, an angle expressed in radians.

Parameters:
NameTypeDescription
inumberstring | number

A complex number for which you want the argument Theta

See
Returns:

The argument Theta, an angle expressed in radians, for the given complex number

Type: 
string | number
Example
rosettajs.imArgument("4+5i") // returns 0.8960553845713439

(inner) imConjugate(inumber) → {string|number}

Returns the complex conjugate of a complex number.

Parameters:
NameTypeDescription
inumberstring | number

A complex number for which you want the conjugate

See
Returns:

The complex conjugate of the given complex number

Type: 
string | number
Example
rosettajs.imConjugate("7+4i") // returns 7-4i

(inner) imCos(inumber) → {string|number}

Returns the cosine of a complex number.

Parameters:
NameTypeDescription
inumberstring | number

A complex number for which you want the cosine

See
Returns:

Returns the cosine of the given complex number in x + yi or x + yj text format

Type: 
string | number
Example
rosettajs.imCos("7+i") // returns 1.1633319692207098-0.772091435022302i

(inner) imCosh(inumber) → {string|number}

Returns the hyperbolic cosine of a complex number.

Parameters:
NameTypeDescription
inumberstring | number

A complex number for which you want the hyperbolic cosine

See
Returns:

The hyperbolic cosine of the given complex number in x+yi or x+yj text format

Type: 
string | number
Example
rosettajs.imCosh("7+i") // returns 296.2569584411429+461.3921082367867i

(inner) imCot(inumber) → {string|number}

Returns the cotangent of a complex number.

Parameters:
NameTypeDescription
inumberstring | number

A complex number for which you want the cotangent

See
  • For further information, see   docs.oasis-open.org
Returns:

The cotangent of the given complex number in x+yi or x+yj text format

Type: 
string | number
Example
rosettajs.imCot("7+i") // returns 0.27323643702063916-1.0003866917747672i

(inner) imCsc(inumber) → {string|number}

Returns the cosecant of a complex number.

Parameters:
NameTypeDescription
inumberstring | number

A complex number for which you want the cosecant

See
  • For further information, see   docs.oasis-open.org
Returns:

The cosecant of a complex number in x+yi or x+yj text format

Type: 
string | number
Example
rosettajs.imCsc("7+i") // returns 0.5592579837285742-0.48875850368917295i

(inner) imCsch(inumber) → {string|number}

Returns the hyperbolic cosecant of a complex number.

Parameters:
NameTypeDescription
inumberstring | number

A complex number for which you want the hyperbolic cosecant

See
  • For further information, see   docs.oasis-open.org
Returns:

The hyperbolic cosecant of the given complex number in x+yi or x+yj text format

Type: 
string | number
Example
rosettajs.imCsch("7+i") // returns 0.0009853823560021253-0.0015346446451764265i

(inner) imDiv(inumber1, inumber2) → {string|number}

Returns the quotient of two complex numbers.

Parameters:
NameTypeDescription
inumber1string | number

The complex numerator or dividend

inumber2string | number

The complex denominator or divisor

See
  • For further information, see   docs.oasis-open.org
Returns:

The quotient of the two given complex numbers in x + yi or x + yj text format

Type: 
string | number
Example
rosettajs.imDiv("-238+240i","10+24i") // returns 5+12i

(inner) imExp(inumber) → {string|number}

Returns the exponential of a complex number.

Parameters:
NameTypeDescription
inumberstring | number

A complex number for which you want the exponential

See
  • For further information, see   docs.oasis-open.org
Returns:

The exponential of a complex number in x + yi or x + yj text format

Type: 
string | number
Example
rosettajs.imExp("2+i") // returns 3.992324048441272+6.217676312367968i

(inner) imLn(inumber) → {string|number}

Returns the natural logarithm of a complex number.

Parameters:
NameTypeDescription
inumberstring | number

A complex number for which you want the natural logarithm

See
  • For further information, see   docs.oasis-open.org
Returns:

The natural logarithm of a complex number in x + yi or x + yj text format

Type: 
string | number
Example
rosettajs.imLn("2+i") // returns 0.8047189562170503+0.4636476090008061i

(inner) imLog2(inumber) → {string|number}

Returns the base-2 logarithm of a complex number.

Parameters:
NameTypeDescription
inumberstring | number

A complex number for which you want the base-2 logarithm

See
  • For further information, see   docs.oasis-open.org
Returns:

The base-2 logarithm of a complex number in x + yi or x + yj text format

Type: 
string | number
Example
rosettajs.imLog2("7+i") // returns 2.821928094887362+0.20471417699417774i

(inner) imLog10(inumber) → {string|number}

Returns the base-10 logarithm of a complex number.

Parameters:
NameTypeDescription
inumberstring | number

A complex number for which you want the common logarithm

See
  • For further information, see   docs.oasis-open.org
Returns:

The common logarithm (base 10) of a complex number in x + yi or x + yj text format.

Type: 
string | number
Example
rosettajs.imLog10("7+i") // returns 0.8494850021680093+0.06162510781291279i

(inner) imPower(inumber, power) → {string|number}

Returns a complex number raised to an integer power.

Parameters:
NameTypeDescription
inumberstring | number

A complex number you want to raise to a power

powernumber

The power to which you want to raise the complex number

See
  • For further information, see   docs.oasis-open.org
Returns:

A complex number in x + yi or x + yj text format raised to a power

Type: 
string | number
Example
rosettajs.imPower("2+2i", 55) // returns 4.835703278458551e+24-4.835703278458541e+24i

(inner) imProduct(…inumbers) → {string|number}

Returns the product of from 2 to 255 complex numbers.

Parameters:
NameTypeAttributesDescription
inumbersArray.<string> | Array.<number><repeatable>

Inumber1 is required, subsequent inumbers are not. 1 to 255 complex numbers to multiply

See
  • For further information, see   docs.oasis-open.org
Returns:

The product of 1 to 255 complex numbers in x + yi or x + yj text format

Type: 
string | number
Examples
rosettajs.imProduct("7+2i",55) // returns 385+110i
rosettajs.imProduct("7+2i","9-3i") // returns 69-3i

(inner) imReal(inumber) → {string|number}

Returns the real coefficient of a complex number.

Parameters:
NameTypeDescription
inumberstring | number

A complex number for which you want the real coefficient

See
  • For further information, see   docs.oasis-open.org
Returns:

The real coefficient of a complex number in x + yi or x + yj text format

Type: 
string | number
Example
rosettajs.imReal("7-3i") // returns 7

(inner) imSec(inumber) → {String}

Returns the secant of a complex number.

Parameters:
NameTypeDescription
inumbernumber

A complex number for which you want the secant

See
  • For further information, see   docs.oasis-open.org
Returns:

The secant of a complex number in x+yi or x+yj text format.

Type: 
String
Example
rosettajs.imSec("7-3i") // returns 0.07520380314551633-0.06521210988033882i

(inner) imSech(inumber) → {String}

Returns the hyperbolic secant of a complex number.

Parameters:
NameTypeDescription
inumbernumber

A complex number for which you want the hyperbolic secant.

See
  • For further information, see   docs.oasis-open.org
Returns:

The hyperbolic secant of a complex number in x+yi or x+yj text format.

Type: 
String
Example
rosettajs.imSech("7-3i") // returns -0.0018055112256293788+0.00025736895567555834i

(inner) imSin(inumber) → {string|number}

Returns the sine of a complex number.

Parameters:
NameTypeDescription
inumberstring | number

A complex number for which you want the sine

See
  • For further information, see   docs.oasis-open.org
Returns:

The sine of a complex number in x + yi or x + yj text format

Type: 
string | number
Example
rosettajs.imSin("7-3i") // returns 6.61431901165645-7.552498491503594i

(inner) imSinh(inumber) → {string|number}

Returns the hyperbolic sine of a complex number.

Parameters:
NameTypeDescription
inumberstring | number

A complex number for which you want the hyperbolic sine

See
  • For further information, see   docs.oasis-open.org
Returns:

The hyperbolic sine of a complex number in x+yi or x+yj text format

Type: 
string | number
Example
rosettajs.imSinh("7-4i") // returns -358.4033361942234+414.96770042530943i

(inner) imSqrt(inumber) → {string|number}

Returns the square root of a complex number.

Parameters:
NameTypeDescription
inumberstring | number

A complex number for which you want the square root

See
  • For further information, see   docs.oasis-open.org
Returns:

The square root of a complex number in x + yi or x + yj text format.

Type: 
string | number
Example
rosettajs.imSqrt("7-4i") // returns 2.744290231398508-0.7287858904707711i

(inner) imSub(inumber1, inumber2) → {stirng|number}

Returns the difference between two complex numbers.

Parameters:
NameTypeDescription
inumber1string | number

The complex number from which to subtract inumber2

inumber2string | number

The complex number to subtract from inumber1

See
  • For further information, see   docs.oasis-open.org
Returns:

The difference of two complex numbers in x + yi or x + yj text format

Type: 
stirng | number
Example
rosettajs.imSub("15+2i","3+3i") // returns 12-1i

(inner) imSum(…inumbers) → {string|number}

Returns the sum of complex numbers.

Parameters:
NameTypeAttributesDescription
inumbersArray.<string> | Array.<number><repeatable>

Inumber1 is required, subsequent inumbers are not. 1 to 255 complex numbers to add

See
  • For further information, see   docs.oasis-open.org
Returns:

The sum of two or more complex numbers in x + yi or x + yj text format

Type: 
string | number
Examples
rosettajs.imSum("7+2i",55) // returns 755+2i
rosettajs.imSum("7+2i","9-3i") // returns 16-1i

(inner) imTan(inumber) → {string|number}

Returns the tangent of a complex number.

Parameters:
NameTypeDescription
inumberstring | number

A complex number for which you want the tangent

See
  • For further information, see   docs.oasis-open.org
Returns:

The tangent of a complex number in x+yi or x+yj text format

Type: 
string | number
Example
rosettajs.imTan("7+2i") // returns 0.03609431359326245+0.9943504089532537i

(inner) oct2Bin(number, placesopt) → {number}

Converts an octal number to binary.

Parameters:
NameTypeAttributesDescription
numberstring

The octal number you want to convert. Number may not contain more than 10 characters. The most significant bit of number is the sign bit. The remaining 29 bits are magnitude bits. Negative numbers are represented using two's-complement notation.

placesnumber<optional>

The number of characters to use. If places is omitted, oct2Bin uses the minimum number of characters necessary. Places is useful for padding the return value with leading 0s (zeros).

See
  • For further information, see   docs.oasis-open.org
Returns:

A binary for the given octal number

Type: 
number
Examples
rosettajs.oct2Bin(7) // returns 111
rosettajs.oct2Bin(7, 5) // returns 00111

(inner) oct2Dec(number) → {number}

Converts an octal number to decimal.

Parameters:
NameTypeDescription
numberstring

The octal number you want to convert. Number may not contain more than 10 octal characters (30 bits). The most significant bit of number is the sign bit. The remaining 29 bits are magnitude bits. Negative numbers are represented using two's-complement notation.

See
  • For further information, see   docs.oasis-open.org
Returns:

A decimal for the given octal number

Type: 
number
Example
rosettajs.oct2Dec(64) // returns 52

(inner) oct2Hex(number, placesopt) → {number}

Converts an octal number to hexadecimal.

Parameters:
NameTypeAttributesDescription
numberstring

The octal number you want to convert. Number may not contain more than 10 octal characters (30 bits). The most significant bit of number is the sign bit. The remaining 29 bits are magnitude bits. Negative numbers are represented using two's-complement notation

placesnumber<optional>

The number of characters to use. If places is omitted, OCT2HEX uses the minimum number of characters necessary. Places is useful for padding the return value with leading 0s (zeros).

See
  • For further information, see   docs.oasis-open.org
Returns:

A hexadecimal for the given octal number

Type: 
number
Examples
rosettajs.oct2Hex(177747533) // returns 1ffcf5b
rosettajs.oct2Hex(74,5) // returns 0003c