CFLib.org – Common Function Library Project

ComplexNumToString(ComplexNumber)

Last updated November 15, 2001

author

Matthew Walker

Version: 1 | Requires: CF5 | Library: MathLib

Description:
Convert a complex number stored as a structure by the Complex() UDF to a human readable form: a+bi. This is primarily intended as a quick output for debugging.

Return Values:
Returns a string

Example:

<cfoutput>
	<cfset z=ComplexNum(3,-10)>
	z = #ComplexNumToString(z)#
</cfoutput>

Parameters:

Name Description Required
ComplexNumber Structure containing complex number you want converted to a string. Yes

Full UDF Source:

/**
 * Convert a stored complex number to a string in the form a + bi.
 * Note that this function uses complex numbers stored as structures by the ComplexNum() UDF also available in this library.
 * 
 * @param ComplexNumber 	 Structure containing complex number you want converted to a string. 
 * @return Returns a string 
 * @author Matthew Walker (matthew@electricsheep.co.nz) 
 * @version 1, November 15, 2001 
 */
function ComplexNumToString(ComplexNumber) {
  if ( ComplexNumber.I LT 0 )
    return "#ComplexNumber.R# - #Abs(ComplexNumber.I)#i";
  else		
    return "#ComplexNumber.R# + #ComplexNumber.I#i";
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson