<divclass="link title"><ahref="/v5/">Documentation</a></div><divclass="base show link depth-1"><ahref="/v5/getting-started/">Getting Started</a></div><divclass="base show link depth-1"><ahref="/v5/concepts/">Ethereum Basics</a></div><divclass="hide link depth-2"><ahref="/v5/concepts/events/">Events</a></div><divclass="hide link depth-2"><ahref="/v5/concepts/gas/">Gas</a></div><divclass="hide link depth-2"><ahref="/v5/concepts/security/">Security</a></div><divclass="base ancestor show link depth-1"><ahref="/v5/api/">Application Programming Interface</a></div><divclass="show link depth-2"><ahref="/v5/api/contract/">Contract Interaction</a></div><divclass="hide link depth-3"><ahref="/v5/api/contract/contract/">Contract</a></div><divclass="hide link depth-3"><ahref="/v5/api/contract/contract-factory/">ContractFactory</a></div><divclass="hide link depth-3"><ahref="/v5/api/contract/example/">Example: ERC-20 Contract</a></div><divclass="show link depth-2"><ahref="/v5/api/signer/">Signers</a></div><divclass="show link depth-2"><ahref="/v5/api/providers/">Providers</a></div><divclass="hide link depth-3"><ahref="/v5/api/providers/provider/">Provider</a></div><divclass="hide link depth-3"><ahref="/v5/api/providers/jsonrpc-provider/">JsonRpcProvider</a></div><divclass="hide link depth-3"><ahref="/v5/api/providers/api-providers/">API Providers</a></div><divclass="hide link depth-3"><ahref="/v5/api/providers/other/">Other Providers</a></div><divclass="hide link depth-3"><ahref="/v5/api/providers/types/">Types</a></div><divclass="ancestor show link depth-2"><ahref="/v5/api/utils/">Utilities</a></div><divclass="show link depth-3"><ahref="/v5/api/utils/abi/">Application Binary Interface</a></div><divclass="hide link depth-4"><ahref="/v5/api/utils/abi/coder/">AbiCoder</a></div><divclass="hide link depth-4"><ahref="/v5/api/utils/abi/formats/">ABI Formats</a></div><divclass="hide link depth-4"><ahref="/v5/api/utils/abi/fragments/">Fragments</a></div><divclass="hide link depth-4"><ahref="/v5/api/utils/abi/interface/">Interface</a></div><divclass="show link depth-3"><ahref="/v5/api/utils/address/">Addresses</a></div><divclass="show link depth-3"><ahref="/v5/api/utils/bignumber/">BigNumber</a></div><divclass="show link depth-3"><ahref="/v5/api/utils/bytes/">Byte Manipulation</a></div><divclass="show link depth-3"><ahref="/v5/api/utils/constants/">Constants</a></div><divclass="show link depth-3"><ahref="/v5/api/utils/display-logic/">Display Logic and Input</a></div><divclass="show link depth-3"><ahref="/v5/api/utils/encoding/">Encoding Utilities</a></div><divclass="myself ancestor ancestor show link depth-3"><ahref="/v5/api/utils/fixednumber/">FixedNumber</a></div><divclass="show link depth-3"><ahref="/v5/api/utils/hashing/">Hashing Algorithms</a></div><divclass="show link depth-3"><ahref="/v5/api/utils/hdnode/">HD Wallet</a></div><divclass="show link depth-3"><ahref="/v5/api/utils/logger/">Logging</a></div><divclass="show link depth-3"><ahref="/v5/api/utils/properties/">Property Utilities</a></div><divclass="show link depth-3"><ahref="/v5/api/utils/signing-key/">Signing Key</a></div><divclass="show link depth-3"><ahref="/v5/api/utils/strings/">Strings</a></div><divclass="show link depth-3"><ahref="/v5/api/utils/transactions/">Transactions</a></div><divclass="show link depth-3"><ahref="/v5/api/utils/web/">Web Utilities</a></div><divclass="show link depth-3"><ahref="/v5/api/utils/wordlists/">Wordlists</a></div><divclass="show link depth-2"><ahref="/v5/api/other/">Other Libraries</a></div><divclass="hide link depth-3"><ahref="/v5/api/other/assembly/">Assembly</a></div><divclass="hide link depth-4"><ahref="/v5/api/other/assembly/dialect/">Ethers ASM Dialect</a></div><divclass="hide link depth-4"><ahref="/v5/api/other/assembly/api/">Utilities</a></div><divclass="hide link depth-4"><ahref="/v5/api/other/assembly/ast/">Abstract Syntax Tree</a></div><divclass="hide link depth-3"><ahref="/v5/api/other/hardware/">Hardware Wallets</a></div><divclass="sho
<aname="FixedNumber"></a><aname="FixedNumber"></a><h1class="show-anchors"><div>FixedNumber<divclass="anchors"><aclass="self"href="/v5/api/utils/fixednumber/#FixedNumber"></a></div></div></h1><p>A <b>FixedNumber</b> is a fixed-width (in bits) number with an internal base-10 divisor, which allows it to represent a decimal fractional component.</p>
<aname="FixedNumber--creating-instances"></a><h2class="show-anchors"><div>Creating Instances<divclass="anchors"><aclass="self"href="/v5/api/utils/fixednumber/#FixedNumber--creating-instances"></a></div></div></h2><p>The FixedNumber constructor cannot be called directly. There are several static methods for creating a FixedNumber.</p>
<divclass="property show-anchors"><divclass="signature"><spanclass="path">FixedNumber</span><spanclass="symbol">.</span><spanclass="method">from</span><spanclass="symbol">(</span><spanclass="param">value</span><spanclass="symbol">[</span><spanclass="symbol">,</span><spanclass="param">format</span> = "<spanclass="param">fixed</span>" <spanclass="symbol">]</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns"><ahref="/v5/api/utils/fixednumber/">FixedNumber</a></span><divclass="anchors"><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/fixednumber.ts#L339">source</a></div></div><divclass="body"><p>Returns an instance of a <b>FixedNumber</b> for <i>value</i> as a <i>format</i>.</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">FixedNumber</span><spanclass="symbol">.</span><spanclass="method">fromBytes</span><spanclass="symbol">(</span><spanclass="param">aBytesLike</span><spanclass="symbol">[</span><spanclass="symbol">,</span><spanclass="param">format</span> = "<spanclass="param">fixed</span>" <spanclass="symbol">]</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns"><ahref="/v5/api/utils/fixednumber/">FixedNumber</a></span><divclass="anchors"><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/fixednumber.ts#L321">source</a></div></div><divclass="body"><p>Returns an instance of a <b>FixedNumber</b> for <i>value</i> as a <i>format</i>.</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">FixedNumber</span><spanclass="symbol">.</span><spanclass="method">fromString</span><spanclass="symbol">(</span><spanclass="param">value</span><spanclass="symbol">[</span><spanclass="symbol">,</span><spanclass="param">format</span> = "<spanclass="param">fixed</span>" <spanclass="symbol">]</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns"><ahref="/v5/api/utils/fixednumber/">FixedNumber</a></span><divclass="anchors"><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/fixednumber.ts#L297">source</a></div></div><divclass="body"><p>Returns an instance of a <b>FixedNumber</b> for <i>value</i> as a <i>format</i>. The <i>value</i> must not contain more decimals than the <i>format</i> permits.</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">FixedNumber</span><spanclass="symbol">.</span><spanclass="method">fromValue</span><spanclass="symbol">(</span><spanclass="param">value</span><spanclass="symbol">[</span><spanclass="symbol">,</span><spanclass="param">decimals</span> = <spanclass="param">0</span><spanclass="symbol">[</span><spanclass="symbol">,</span><spanclass="param">format</span> = "<spanclass="param">fixed</span>" <spanclass="symbol">]</span><spanclass="symbol">]</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns"><ahref="/v5/api/utils/fixednumber/">FixedNumber</a></span><divclass="anchors"><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/fixednumber.ts#L283">source</a></div></div><divclass="body"><p>Returns an instance of a <b>FixedNumber</b> for <i>value</i> with <i>decimals</i> as a <i>format</i>.</p>
<divclass="property show-anchors"><divclass="signature"><spanclass="path">fixednumber</span><spanclass="symbol">.</span><spanclass="method">format</span><divclass="anchors"></div></div><divclass="body"><p>The <ahref="/v5/api/utils/fixednumber/#FixedFormat">FixedFormat</a> of <i>fixednumber</i>.</p>
<divclass="property show-anchors"><divclass="signature"><spanclass="path">fixednumber</span><spanclass="symbol">.</span><spanclass="method">addUnsafe</span><spanclass="symbol">(</span><spanclass="param">otherValue</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns"><ahref="/v5/api/utils/fixednumber/">FixedNumber</a></span><divclass="anchors"><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/fixednumber.ts#L215">source</a></div></div><divclass="body"><p>Returns a new FixedNumber with the value of <i>fixedvalue</i><b>+</b><i>otherValue</i>.</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">fixednumber</span><spanclass="symbol">.</span><spanclass="method">subUnsafe</span><spanclass="symbol">(</span><spanclass="param">otherValue</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns"><ahref="/v5/api/utils/fixednumber/">FixedNumber</a></span><divclass="anchors"><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/fixednumber.ts#L222">source</a></div></div><divclass="body"><p>Returns a new FixedNumber with the value of <i>fixedvalue</i><b>-</b><i>otherValue</i>.</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">fixednumber</span><spanclass="symbol">.</span><spanclass="method">mulUnsafe</span><spanclass="symbol">(</span><spanclass="param">otherValue</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns"><ahref="/v5/api/utils/fixednumber/">FixedNumber</a></span><divclass="anchors"><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/fixednumber.ts#L229">source</a></div></div><divclass="body"><p>Returns a new FixedNumber with the value of <i>fixedvalue</i><b>×</b><i>otherValue</i>.</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">fixednumber</span><spanclass="symbol">.</span><spanclass="method">divUnsafe</span><spanclass="symbol">(</span><spanclass="param">otherValue</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns"><ahref="/v5/api/utils/fixednumber/">FixedNumber</a></span><divclass="anchors"><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/fixednumber.ts#L236">source</a></div></div><divclass="body"><p>Returns a new FixedNumber with the value of <i>fixedvalue</i><b>÷</b><i>otherValue</i>.</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">fixednumber</span><spanclass="symbol">.</span><spanclass="method">round</span><spanclass="symbol">(</span><spanclass="symbol">[</span><spanclass="param">decimals</span> = <spanclass="param">0</span><spanclass="symbol">]</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns"><ahref="/v5/api/utils/fixednumber/">FixedNumber</a></span><divclass="anchors"><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/fixednumber.ts#L244">source</a></div></div><divclass="body"><p>Returns a new FixedNumber with the value of <i>fixedvalue</i> rounded to <i>decimals</i>.</p>
</div></div><aname="FixedNumber--methods--comparison-and-equivalence"></a><h3class="show-anchors"><div>Comparison and Equivalence<divclass="anchors"><aclass="self"href="/v5/api/utils/fixednumber/#FixedNumber--methods--comparison-and-equivalence"></a></div></div></h3>
<divclass="property show-anchors"><divclass="signature"><spanclass="path">FixedNumber</span><spanclass="symbol">.</span><spanclass="method">isZero</span><spanclass="symbol">(</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">boolean</span><divclass="anchors"><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/fixednumber.ts#L262">source</a></div></div><divclass="body"><p>Returns true if and only if the value of <i>FixedNumber</i> is zero.</p>
<divclass="property show-anchors"><divclass="signature"><spanclass="path">fixednumber</span><spanclass="symbol">.</span><spanclass="method">toFormat</span><spanclass="symbol">(</span><spanclass="param">format</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns"><ahref="/v5/api/utils/fixednumber/">FixedNumber</a></span><divclass="anchors"><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/fixednumber.ts#L278">source</a></div></div><divclass="body"><p>Returns a new FixedNumber with the value of <i>fixedvalue</i> with <i>format</i>.</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">fixednumber</span><spanclass="symbol">.</span><spanclass="method">toHexString</span><spanclass="symbol">(</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">string</span><divclass="anchors"><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/fixednumber.ts#L269">source</a></div></div><divclass="body"><p>Returns a <ahref="/v5/api/utils/bytes/#HexString">HexString</a> representation of <i>fixednumber</i>.</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">fixednumber</span><spanclass="symbol">.</span><spanclass="method">toString</span><spanclass="symbol">(</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">string</span><divclass="anchors"><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/fixednumber.ts#L267">source</a></div></div><divclass="body"><p>Returns a string representation of <i>fixednumber</i>.</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">fixednumber</span><spanclass="symbol">.</span><spanclass="method">toUnsafeFloat</span><spanclass="symbol">(</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">float</span><divclass="anchors"><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/fixednumber.ts#L276">source</a></div></div><divclass="body"><p>Returns a floating-point JavaScript number value of <i>fixednumber</i>. Due to rounding in JavaScript numbers, the value is only approximate.</p>
<divclass="property show-anchors"><divclass="signature"><spanclass="path">FixedNumber</span><spanclass="symbol">.</span><spanclass="method">isFixedNumber</span><spanclass="symbol">(</span><spanclass="param">value</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">boolean</span><divclass="anchors"><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/fixednumber.ts#L360">source</a></div></div><divclass="body"><p>Returns true if and only if <i>value</i> is a <b>FixedNumber</b>.</p>
</div></div><aname="FixedFormat"></a><aname="FixedNumber--FixedFormat"></a><h2class="show-anchors"><div>FixedFormat<divclass="anchors"><aclass="self"href="/v5/api/utils/fixednumber/#FixedFormat"></a></div></div></h2><p>A <b>FixedFormat</b> is a simple object which represents a decimal (base-10) Fixed-Point data representation. Usually using this class directly is uneccessary, as passing in a <ahref="/v5/api/utils/fixednumber/#FixedFormat--strings">Format Strings</a> directly into the <ahref="/v5/api/utils/fixednumber/">FixedNumber</a> will automatically create this.</p>
<aname="FixedFormat--strings"></a><aname="FixedNumber--FixedFormat--FixedFormat--strings"></a><h3class="show-anchors"><div>Format Strings<divclass="anchors"><aclass="self"href="/v5/api/utils/fixednumber/#FixedFormat--strings"></a></div></div></h3><p>A format string is composed of three components, including signed-ness, bit-width and number of decimals.</p>
<p>A signed format string begins with <codeclass="inline">fixed</code>, which an unsigned format string begins with <codeclass="inline">ufixed</code>, followed by the width (in bits) and the number of decimals.</p>
<p>The width must be conguent to 0 mod 8 (i.e. <codeclass="inline">(width % 8) == 0</code>) and no larger than 256 bits and the number of decimals must be no larger than 80.</p>
<p>For example:</p>
<p><ul><li><b>fixed128x18</b> is signed, 128 bits wide and has 18 decimals; this is useful for most purposes </li><li><b>fixed32x0</b> is signed, 32 bits wide and has 0 decimals; this would be the same as a <codeclass="inline">int32_t</code> in C </li><li><b>ufixed32x0</b> is unsigned, 32 bits wide and has 0 decimals; this would be the same as a <codeclass="inline">uint32_t</code> in C </li><li><b>fixed</b> is shorthand for <codeclass="inline">fixed128x18</code></li><li><b>ufixed</b> is shorthand for <codeclass="inline">ufixed128x18</code></li></ul></p>
<aname="FixedNumber-from"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">FixedFormat</span><spanclass="symbol">.</span><spanclass="method">from</span><spanclass="symbol">(</span><spanclass="param">value</span> = "<spanclass="param">fixed128x18</span>" <spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns"><ahref="/v5/api/utils/fixednumber/#FixedFormat">FixedFormat</a></span><divclass="anchors"><aclass="self"href="/v5/api/utils/fixednumber/#FixedNumber-from"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/fixednumber.ts#L140">source</a></div></div><divclass="body"><p>Returns a new instance of a <b>FixedFormat</b> defined by <i>value</i>. Any valid <ahref="/v5/api/utils/fixednumber/#FixedFormat--strings">Format Strings</a> may be passed in as well as any object which has any of <codeclass="inline">signed</code>, <codeclass="inline">width</code> and <codeclass="inline">decimals</code> defined, including a <ahref="/v5/api/utils/fixednumber/#FixedFormat">FixedFormat</a> object.</p>
<divclass="property show-anchors"><divclass="signature"><spanclass="path">fixedFormat</span><spanclass="symbol">.</span><spanclass="method">signed</span><spanclass="arrow">⇒</span><spanclass="returns">boolean</span><divclass="anchors"></div></div><divclass="body"><p>The signed-ness of <i>fixedFormat</i>, true if negative values are supported.</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">fixedFormat</span><spanclass="symbol">.</span><spanclass="method">width</span><spanclass="arrow">⇒</span><spanclass="returns">number</span><divclass="anchors"></div></div><divclass="body"><p>The width (in bits) of <i>fixedFormat</i>.</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">fixedFormat</span><spanclass="symbol">.</span><spanclass="method">decimals</span><spanclass="arrow">⇒</span><spanclass="returns">number</span><divclass="anchors"></div></div><divclass="body"><p>The number of decimal points of <i>fixedFormat</i>.</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">fixedFormat</span><spanclass="symbol">.</span><spanclass="method">name</span><spanclass="arrow">⇒</span><spanclass="returns">string</span><divclass="anchors"></div></div><divclass="body"><p>The name of the <i>fixedFormat</i>, which can be used to recreate the format and is the string that the Solidity language uses to represent this format.</p>
</div></div><divclass="definition"><divclass="term"><b><i>"fixed"</i></b></div><divclass="body"><p>A shorthand for <codeclass="inline">fixed128x80</code>.</p>
<divclass="copyright">The content of this site is licensed under the <ahref="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>