CFLib.org – Common Function Library Project

ComplexNumToString(ComplexNumber)

Last updated November 15, 2001

Version: 1 | Requires: ColdFusion 5 | Library: MathLib

 
Rated 0 time(s). Average Rating: 0

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:

view plain print about
<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:

view plain print about
<cfscript>
/**
 * 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";
}
</cfscript>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Dave Anderson Dave Anderson added
iniToStruct
20 day(s) ago

Dave Anderson Dave Anderson added
deDupeArray
20 day(s) ago

Richard Richard added
dice
22 day(s) ago

Isaac Dealey Isaac Dealey added
getRelative
a while ago

Top Rated

Darwan Leonardo Sitepu backupDatabase
Rated 5.0, 22 time(s)

Barney Boisvert indentXml
Rated 5.0, 10 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 4 time(s)

Raymond Camden highlightAndCrop
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson