Skip to main content

DecimalString

Git Source

Functions

toDecimalString

Converts a uint256 value to a string with a specified number of decimal places. The value is adjusted by the scale factor and then formatted to the specified number of decimal places. The decimal places are not zero-padded, so the result is not always the same length.

This is inspired by code in FixedStrikeOptionTeller.

function toDecimalString(uint256 value_, uint8 valueDecimals_, uint8 decimalPlaces_)
internal
pure
returns (string memory);

Parameters

NameTypeDescription
value_uint256The uint256 value to convert to a string.
valueDecimals_uint8The scale factor of the value.
decimalPlaces_uint8The number of decimal places to format the value to.

Returns

NameTypeDescription
<none>stringresult A string representation of the value with the specified number of decimal places.