Handling of Complex Numbers in the $C^H$ Programming Language

  • Authors:
  • Harry H. Cheng

  • Affiliations:
  • Department of Mechanical and Aeronautical Engineering, University of California, Davis, CA 95616

  • Venue:
  • Scientific Programming
  • Year:
  • 1993

Quantified Score

Hi-index 0.00

Visualization

Abstract

The handling of complex numbers in the $C^H$ programming language will be described in this paper. Complex is a built-in data type in $C^H$. The I/O, arithmetic and relational operations, and built-in mathematical functions are defined for both regular complex numbers and complex metanumbers of ComplexZero, Complexlnf, and ComplexNaN. Due to polymorphism, the syntax of complex arithmetic and relational operations and built-in mathematical functions are the same as those for real numbers. Besides polymorphism, the built-in mathematical functions are implemented with a variable number of arguments that greatly simplify computations of different branches of multiple-valued complex functions. The valid lvalues related to complex numbers are defined. Rationales for the design of complex features in $C^H$ are discussed from language design, implementation, and application points of views. Sample $C^H$ programs show that a computer language that does not distinguish the sign of zeros in complex numbers can also handle the branch cuts of multiple-valued complex functions effectively so long as it is appropriately designed and implemented.