DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Calculate Argument
Calculate the argument of a complex number using math:: class.
#!/usr/bin/tclsh package require Tcl 8.4 package require math::complexnumbers package require math::constants package require math::statistics # Create Constants ::math::constants::constants radtodeg ::math::constants::constants pi # Perform Operations set z [ ::math::complexnumbers::complex -2 12] set zstring [ ::math::complexnumbers::tostring $z] set comp [ ::math::complexnumbers::arg $z ] set dcomp [ expr $comp * $radtodeg] # Results puts "::math::complexnumbers::arg returned $comp rad ($dcomp deg) for the complex number $zstring"





