OpenViSTAI · Agents · Blockchain · Crypto
Menu
Developer Tools

Num Complex Solidity

Num Complex Solidity is an MIT-licensed internal Solidity library for complex-number arithmetic built on PRBMath’s signed 59.18-decimal fixed-point type. Its functions cover basic operations, polar conversions and principal complex functions; consuming contracts include only the reachable implementation rather than deploying a separate helper contract.

Independent OpenViST project profile, based on linked sources.

Num Complex Solidity — OpenViST project profile in Developer Tools.
OpenViST project illustration. See the linked sources for product details.
Understand the project

Practical overview

When it fits

Consider it when contract logic requires complex arithmetic and its fixed-point representation, approximation limits and revert conditions fit the calculation. Prefer `powu` for unsigned integer powers; assess the principal-branch behavior and exponent-related phase error before choosing general `pow`.

Who it is for

  • Solidity developers building contracts that require complex-number calculations.
  • Developers evaluating fixed-point mathematical operations for decentralized finance contracts.

Documented uses

  • Represent complex values with fixed-point real and imaginary components.
  • Perform arithmetic such as addition, multiplication, division and integer powers in a contract.
  • Calculate magnitude, convert between Cartesian and polar forms, or use complex square-root, logarithm and exponential functions.
Before you choose

Requirements & limits

The repository is public and identifies the library as MIT licensed.

  • The library depends on PRBMath’s SD59x18 type, so inputs and outputs use 18-decimal fixed-point scaling.
  • Exact operations may revert when results or required intermediates overflow; division by zero has a library-specific error.
  • Approximate operations have stated domain limits and error bounds. For example, atan2 has a maximum stated polynomial error of 0.00151 radians, and trigonometric functions document an angle range from 0 through 1e10 ra
  • The README’s representative gas figures use a 1,000-run optimizer and IR pipeline on the Prague EVM and may vary in a consuming contract.
  • The project documents both Foundry dependency installation and npm installation with Solidity remappings.

Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.

Source-based practical guide

Add the library to a Foundry project

Install the library and its PRBMath dependency, then configure the documented import remappings.

Before you start

  • A Solidity project using Foundry
  • PRBMath v4.2.0 as the documented dependency

Steps

  1. Install both dependencies with the documented Foundry command, pinning PRBMath to v4.2.0.

  2. Add the remappings @prb/math/=lib/prb-math/ and num_complex_solidity/=lib/num-complex-solidity/.

  3. Import SD59x18, sd, Complex and ComplexMath from the documented paths in a Solidity consumer.

Expected outcome

The project has the dependency paths needed to use ComplexMath in a consuming contract.

Guide limitations

  • This setup does not establish that a consumer contract compiles or behaves correctly.
  • Operations can revert on overflow, unsupported domains or division by zero, as applicable.
Source-based practical guide

Install through npm and configure Solidity remappings

Set up the documented node_modules dependency paths for a Solidity consumer.

Before you start

  • A project that resolves Solidity packages through node_modules
  • npm

Steps

  1. Install num_complex_solidity and @prb/math with the documented npm command.

  2. Configure @prb/math/=node_modules/@prb/math/ and num_complex_solidity/=node_modules/num_complex_solidity/ remappings.

  3. Use the documented import paths for PRBMath and the complex-number library in the Solidity consumer.

Expected outcome

The project has the documented package locations and remappings for importing the library.

Guide limitations

  • The README describes this as an installation path; it does not document a complete consumer build or deployment procedure.
Evidence and transparency

Sources & review

Source record details
Source availability
Active
Sources checked
10 October 2026
Original website title
partylikeits1983/num-complex-solidity · Official homepage title · retained in its source language