# BigDecimal

<div class="jsdoc-content"><header>
    
        <h2><span class="attribs"><span class="type-signature"></span></span>
            <span class="ancestors"><a href="index.html">types</a>~</span>BigDecimal<span class="signature">(unscaledValue, scale)</span><span class="type-signature"></span></h2>
        
            <div class="class-description"><p>The <code>BigDecimal</code> class provides operations for
arithmetic, scale manipulation, rounding, comparison and
format conversion. The #toString method provides a
canonical representation of a <code>BigDecimal</code>.</p></div>
        
    
</header>


    
        

    
    </div>

## Constructor

<div class="jsdoc-content">
    

    
    <h4 class="name" id="BigDecimal"><span class="type-signature"></span>new BigDecimal<span class="signature">(unscaledValue, scale)</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Constructs an immutable arbitrary-precision signed decimal number.
A <code>BigDecimal</code> consists of an <a href="Integer.html">arbitrary precision integer</a>
<em>unscaled value</em> and a 32-bit integer <em>scale</em>. If zero
or positive, the scale is the number of digits to the right of the
decimal point. If negative, the unscaled value of the number is
multiplied by ten to the power of the negation of the scale. The
value of the number represented by the <code>BigDecimal</code> is
therefore (unscaledValue x 10^(-scale)).</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params docutils align-default">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>unscaledValue</code></td>
            

            <td class="type">
            
            </td>

            

            

            <td class="description last"><p>The integer part of the decimal.</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>scale</code></td>
            

            <td class="type">
            
            </td>

            

            

            <td class="description last"><p>The scale of the decimal.</p></td>
        </tr>

    
    </tbody>
</table>






<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/types/big-decimal.ts#L12" target="_blank" rel="noopener">types/big-decimal.ts, line 12</a></p></div>




















    
    

    

    

    

    

    

    

    

    
        </div>

## Methods

<div class="jsdoc-content">

        
            

    

    
    <h4 class="name" id="add"><span class="type-signature"></span>add<span class="signature">(other)</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Returns the sum of this and the given BigDecimal.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params docutils align-default">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>other</code></td>
            

            <td class="type">
            
            </td>

            

            

            <td class="description last"><p>The BigDecimal to sum to this.</p></td>
        </tr>

    
    </tbody>
</table>






<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/types/big-decimal.ts#L167" target="_blank" rel="noopener">types/big-decimal.ts, line 167</a></p></div>















<h5>Returns:</h5>

        
<div class="param-desc">
    <p>The BigDecimal result.</p>
</div>



    





        
            

    

    
    <h4 class="name" id="compare"><span class="type-signature"></span>compare<span class="signature">(other)</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Compares this BigDecimal with the given one.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params docutils align-default">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>other</code></td>
            

            <td class="type">
            
            </td>

            

            

            <td class="description last"><p>Integer to compare against.</p></td>
        </tr>

    
    </tbody>
</table>






<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/types/big-decimal.ts#L118" target="_blank" rel="noopener">types/big-decimal.ts, line 118</a></p></div>















<h5>Returns:</h5>

        
<div class="param-desc">
    <p>0 if they are the same, 1 if the this is greater, and -1
if the given one is greater.</p>
</div>



    





        
            

    

    
    <h4 class="name" id="equals"><span class="type-signature"></span>equals<span class="signature">()</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Returns true if the value of the BigDecimal instance and other are the same</p>
</div>













<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/types/big-decimal.ts#L100" target="_blank" rel="noopener">types/big-decimal.ts, line 100</a></p></div>




















        
            

    

    
    <h4 class="name" id="greaterThan"><span class="type-signature"></span>greaterThan<span class="signature">()</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Returns true if the current instance is greater than the other</p>
</div>













<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/types/big-decimal.ts#L198" target="_blank" rel="noopener">types/big-decimal.ts, line 198</a></p></div>




















        
            

    

    
    <h4 class="name" id="isNegative"><span class="type-signature"></span>isNegative<span class="signature">()</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Whether this value is negative.</p>
</div>













<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/types/big-decimal.ts#L203" target="_blank" rel="noopener">types/big-decimal.ts, line 203</a></p></div>




















        
            

    

    
    <h4 class="name" id="isZero"><span class="type-signature"></span>isZero<span class="signature">()</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Whether this value is zero.</p>
</div>













<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/types/big-decimal.ts#L208" target="_blank" rel="noopener">types/big-decimal.ts, line 208</a></p></div>




















        
            

    

    
    <h4 class="name" id="subtract"><span class="type-signature"></span>subtract<span class="signature">(other)</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Returns the difference of this and the given BigDecimal.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params docutils align-default">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>other</code></td>
            

            <td class="type">
            
            </td>

            

            

            <td class="description last"><p>The BigDecimal to subtract from this.</p></td>
        </tr>

    
    </tbody>
</table>






<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/types/big-decimal.ts#L134" target="_blank" rel="noopener">types/big-decimal.ts, line 134</a></p></div>















<h5>Returns:</h5>

        
<div class="param-desc">
    <p>The BigDecimal result.</p>
</div>



    





        
            

    

    
    <h4 class="name" id="toJSON"><span class="type-signature"></span>toJSON<span class="signature">()</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Returns the string representation.
Method used by the native JSON.stringify() to serialize this instance.</p>
</div>













<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/types/big-decimal.ts#L251" target="_blank" rel="noopener">types/big-decimal.ts, line 251</a></p></div>




















        
            

    

    
    <h4 class="name" id="toNumber"><span class="type-signature"></span>toNumber<span class="signature">()</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Returns a Number representation of this <code>BigDecimal</code>.</p>
</div>













<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/types/big-decimal.ts#L243" target="_blank" rel="noopener">types/big-decimal.ts, line 243</a></p></div>




















        
            

    

    
    <h4 class="name" id="toString"><span class="type-signature"></span>toString<span class="signature">()</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Returns the string representation of this BigDecimal</p>
</div>













<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/types/big-decimal.ts#L215" target="_blank" rel="noopener">types/big-decimal.ts, line 215</a></p></div>




















        
            

    

    
    <h4 class="name" id=".fromBuffer"><span class="type-signature">(static) </span>fromBuffer<span class="signature">()</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Returns the BigDecimal representation of a buffer composed of the scale (int32BE) and the unsigned value (varint BE)</p>
</div>













<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/types/big-decimal.ts#L46" target="_blank" rel="noopener">types/big-decimal.ts, line 46</a></p></div>




















        
            

    

    
    <h4 class="name" id=".fromNumber"><span class="type-signature">(static) </span>fromNumber<span class="signature">()</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Returns a BigDecimal representation of the Number</p>
</div>













<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/types/big-decimal.ts#L85" target="_blank" rel="noopener">types/big-decimal.ts, line 85</a></p></div>




















        
            

    

    
    <h4 class="name" id=".fromString"><span class="type-signature">(static) </span>fromString<span class="signature">()</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Returns a BigDecimal representation of the string</p>
</div>













<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/types/big-decimal.ts#L68" target="_blank" rel="noopener">types/big-decimal.ts, line 68</a></p></div>




















        
            

    

    
    <h4 class="name" id=".toBuffer"><span class="type-signature">(static) </span>toBuffer<span class="signature">()</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Returns a buffer representation composed of the scale as a BE int 32 and the unsigned value as a BE varint</p>
</div>













<div class="admonition note"><p class="admonition-title">Source</p><p><a href="https://github.com/scylladb/nodejs-rs-driver/blob/v0.6.1/lib/types/big-decimal.ts#L55" target="_blank" rel="noopener">types/big-decimal.ts, line 55</a></p></div></div>
