OpenViSTAI · Agents · Blockchain · Crypto
Menu
Developer Tools

DSMath

DSMath is a Solidity library for checked unsigned-integer arithmetic, integer comparisons, and fixed-point calculations using 18-decimal wad and 27-decimal ray values.

Independent OpenViST project profile, based on linked sources.

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

Practical overview

When it fits

Use DSMath when Solidity contract logic needs the documented checked integer operations or fixed-point wad and ray helpers.

Who it is for

  • Solidity developers implementing arithmetic in smart contracts.
  • Contract authors working with fixed-point values represented as integers.

Documented uses

  • Add, subtract, and multiply unsigned integers with overflow exceptions.
  • Compare signed or unsigned integers using minimum and maximum helpers.
  • Multiply and divide wad or ray values while retaining their documented precision.
  • Raise a ray value to a power.
Before you choose

Requirements & limits

The repository is public and identifies its license as GPL-3.0.

  • Wads represent fixed-point values with 18 decimal places; rays use 27.
  • Unsigned add, subtract, and multiply return an exception on overflow.
  • The library documents no separate uint division helper; its README attributes division-by-zero checking to the Solidity compiler.
  • The documented ray operations include exponentiation, while the wad operations listed are multiplication and division.

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

Choose DS-Math operations for Solidity values

Use the documented integer and fixed-point arithmetic functions in Solidity contract logic.

Before you start

  • A Solidity contract using unsigned integer, signed integer min/max, wad, or ray values.
  • The DS-Math function names and behaviors described in the project README.

Steps

  1. For checked unsigned integer arithmetic, use add, sub, or mul; these return an exception on overflow.

  2. For comparisons, use min or max for unsigned values, or imin or imax for signed values.

  3. For 18-decimal fixed-point values, use wmul or wdiv; for 27-decimal values, use rmul, rdiv, or rpow.

  4. Keep wad and ray operands in their corresponding fixed-point representation so the functions preserve the documented precision.

Expected outcome

Contract logic can use the documented checked arithmetic, min/max, and wad/ray fixed-point operations.

Guide limitations

  • The README documents no unsigned div function; it says Solidity provides divide-by-zero checking.
  • This guidance describes function selection, not installation, compilation, or testing.
Evidence and transparency

Sources & review

Source record details
Source availability
Active
Sources checked
15 October 2026
Original website title
dapphub/ds-math · Official homepage title · retained in its source language