-
Notifications
You must be signed in to change notification settings - Fork 0
/
io.randomseed.bankster.scale.html
42 lines (42 loc) · 26.3 KB
/
io.randomseed.bankster.scale.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<!DOCTYPE html PUBLIC ""
"">
<html><head><meta charset="UTF-8" /><title>io.randomseed.bankster.scale documentation</title><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="css/highlight.css" /><script type="text/javascript" src="js/highlight.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/page_effects.js"></script><script>hljs.initHighlightingOnLoad();</script><link rel="stylesheet" type="text/css" href="css/randomseed.css" /></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html"><span class="project-title"><span class="project-name">Bankster</span> <span class="project-version">1.2.16</span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 "><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Topics</span></h3><ul><li class="depth-1 "><a href="10_introduction.html"><div class="inner"><span>Introduction</span></div></a></li><li class="depth-1 "><a href="20_data_structures.html"><div class="inner"><span>Data Structures</span></div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>io</span></div></div></li><li class="depth-2"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>randomseed</span></div></div></li><li class="depth-3"><a href="io.randomseed.bankster.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>bankster</span></div></a></li><li class="depth-4 branch"><a href="io.randomseed.bankster.config.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>config</span></div></a></li><li class="depth-4 branch"><a href="io.randomseed.bankster.currency.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>currency</span></div></a></li><li class="depth-4"><a href="io.randomseed.bankster.money.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>money</span></div></a></li><li class="depth-5 branch"><a href="io.randomseed.bankster.money.inter-ops.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>inter-ops</span></div></a></li><li class="depth-5"><a href="io.randomseed.bankster.money.ops.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>ops</span></div></a></li><li class="depth-4 branch"><a href="io.randomseed.bankster.registry.html"><div class="inner"><span class="tree" style="top: -83px;"><span class="top" style="height: 92px;"></span><span class="bottom"></span></span><span>registry</span></div></a></li><li class="depth-4 branch current"><a href="io.randomseed.bankster.scale.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>scale</span></div></a></li><li class="depth-4"><a href="io.randomseed.bankster.util.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>util</span></div></a></li><li class="depth-5 branch"><a href="io.randomseed.bankster.util.fs.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>fs</span></div></a></li><li class="depth-5 branch"><a href="io.randomseed.bankster.util.importer.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>importer</span></div></a></li><li class="depth-5"><a href="io.randomseed.bankster.util.map.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>map</span></div></a></li></ul></div><div class="sidebar secondary"><h3><a href="#top"><span class="inner">Public Vars</span></a></h3><ul><li class="depth-1"><a href="io.randomseed.bankster.scale.html#var-*each*"><div class="inner"><span>*each*</span></div></a></li><li class="depth-1"><a href="io.randomseed.bankster.scale.html#var-*rounding-mode*"><div class="inner"><span>*rounding-mode*</span></div></a></li><li class="depth-1"><a href="io.randomseed.bankster.scale.html#var--.3Edouble"><div class="inner"><span>->double</span></div></a></li><li class="depth-1"><a href="io.randomseed.bankster.scale.html#var--.3Efloat"><div class="inner"><span>->float</span></div></a></li><li class="depth-1"><a href="io.randomseed.bankster.scale.html#var--.3Eint"><div class="inner"><span>->int</span></div></a></li><li class="depth-1"><a href="io.randomseed.bankster.scale.html#var--.3Elong"><div class="inner"><span>->long</span></div></a></li><li class="depth-1"><a href="io.randomseed.bankster.scale.html#var-div-math-context"><div class="inner"><span>div-math-context</span></div></a></li><li class="depth-1"><a href="io.randomseed.bankster.scale.html#var-div-max-precision"><div class="inner"><span>div-max-precision</span></div></a></li><li class="depth-1"><a href="io.randomseed.bankster.scale.html#var-each"><div class="inner"><span>each</span></div></a></li><li class="depth-1"><a href="io.randomseed.bankster.scale.html#var-fractional"><div class="inner"><span>fractional</span></div></a></li><li class="depth-1"><a href="io.randomseed.bankster.scale.html#var-integer"><div class="inner"><span>integer</span></div></a></li><li class="depth-1"><a href="io.randomseed.bankster.scale.html#var-ROUND_CEILING"><div class="inner"><span>ROUND_CEILING</span></div></a></li><li class="depth-1"><a href="io.randomseed.bankster.scale.html#var-ROUND_DOWN"><div class="inner"><span>ROUND_DOWN</span></div></a></li><li class="depth-1"><a href="io.randomseed.bankster.scale.html#var-ROUND_FLOOR"><div class="inner"><span>ROUND_FLOOR</span></div></a></li><li class="depth-1"><a href="io.randomseed.bankster.scale.html#var-ROUND_HALF_DOWN"><div class="inner"><span>ROUND_HALF_DOWN</span></div></a></li><li class="depth-1"><a href="io.randomseed.bankster.scale.html#var-ROUND_HALF_EVEN"><div class="inner"><span>ROUND_HALF_EVEN</span></div></a></li><li class="depth-1"><a href="io.randomseed.bankster.scale.html#var-ROUND_HALF_UP"><div class="inner"><span>ROUND_HALF_UP</span></div></a></li><li class="depth-1"><a href="io.randomseed.bankster.scale.html#var-ROUND_UNNECESSARY"><div class="inner"><span>ROUND_UNNECESSARY</span></div></a></li><li class="depth-1"><a href="io.randomseed.bankster.scale.html#var-ROUND_UP"><div class="inner"><span>ROUND_UP</span></div></a></li><li class="depth-1"><a href="io.randomseed.bankster.scale.html#var-Scalable"><div class="inner"><span>Scalable</span></div></a></li><li class="depth-2 branch"><a href="io.randomseed.bankster.scale.html#var-amount"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>amount</span></div></a></li><li class="depth-2 branch"><a href="io.randomseed.bankster.scale.html#var-applied.3F"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>applied?</span></div></a></li><li class="depth-2 branch"><a href="io.randomseed.bankster.scale.html#var-apply"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>apply</span></div></a></li><li class="depth-2 branch"><a href="io.randomseed.bankster.scale.html#var-of"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>of</span></div></a></li><li class="depth-2"><a href="io.randomseed.bankster.scale.html#var-scalable.3F"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>scalable?</span></div></a></li><li class="depth-1"><a href="io.randomseed.bankster.scale.html#var-to-clojure-string"><div class="inner"><span>to-clojure-string</span></div></a></li><li class="depth-1"><a href="io.randomseed.bankster.scale.html#var-to-clojure-symbol"><div class="inner"><span>to-clojure-symbol</span></div></a></li><li class="depth-1"><a href="io.randomseed.bankster.scale.html#var-to-plain-string"><div class="inner"><span>to-plain-string</span></div></a></li><li class="depth-1"><a href="io.randomseed.bankster.scale.html#var-to-symbol"><div class="inner"><span>to-symbol</span></div></a></li><li class="depth-1"><a href="io.randomseed.bankster.scale.html#var-unscaled-context"><div class="inner"><span>unscaled-context</span></div></a></li><li class="depth-1"><a href="io.randomseed.bankster.scale.html#var-with"><div class="inner"><span>with</span></div></a></li><li class="depth-1"><a href="io.randomseed.bankster.scale.html#var-with-rescaling"><div class="inner"><span>with-rescaling</span></div></a></li><li class="depth-1"><a href="io.randomseed.bankster.scale.html#var-with-rounding"><div class="inner"><span>with-rounding</span></div></a></li></ul></div><div class="namespace-docs" id="content"><h1 class="anchor" id="top">io.randomseed.bankster.scale</h1><div class="doc"><div class="markdown"></div></div><div class="public anchor" id="var-*each*"><h3>*each*</h3><h4 class="dynamic">dynamic</h4><h4 class="added">added in 1.0.0</h4><div class="usage"></div><div class="doc"><div class="markdown"><p>Enables re-scaling after each consecutive operation.</p>
</div></div><div class="src-link"><a href="https://github.com/randomseed-io/bankster/blob/1.2.16/src/io/randomseed/bankster/scale.clj#L35">view source</a></div></div><div class="public anchor" id="var-*rounding-mode*"><h3>*rounding-mode*</h3><h4 class="dynamic">dynamic</h4><h4 class="added">added in 1.0.0</h4><div class="usage"></div><div class="doc"><div class="markdown"><p>Default rounding mode.</p>
</div></div><div class="src-link"><a href="https://github.com/randomseed-io/bankster/blob/1.2.16/src/io/randomseed/bankster/scale.clj#L26">view source</a></div></div><div class="public anchor" id="var--.3Edouble"><h3>->double</h3><h4 class="added">added in 1.1.0</h4><div class="usage"><code>(->double n)</code><code>(->double n scale)</code><code>(->double n rounding-mode)</code><code>(->double n scale rounding-mode)</code></div><div class="doc"><div class="markdown"><p>Converts to a double with optional rescaling and rounding. If the precision of double is to small to express the value, rounding must be provided (either explicitly or using <em>rounding-mode</em>), otherwise an exception will be thrown.</p>
</div></div><div class="src-link"><a href="https://github.com/randomseed-io/bankster/blob/1.2.16/src/io/randomseed/bankster/scale.clj#L476">view source</a></div></div><div class="public anchor" id="var--.3Efloat"><h3>->float</h3><h4 class="added">added in 1.1.0</h4><div class="usage"><code>(->float n)</code><code>(->float n scale)</code><code>(->float n rounding-mode)</code><code>(->float n scale rounding-mode)</code></div><div class="doc"><div class="markdown"><p>Converts to a float with optional rescaling and rounding. If the precision of float is to small to express the value, rounding must be provided (either explicitly or using <em>rounding-mode</em>), otherwise an exception will be thrown.</p>
</div></div><div class="src-link"><a href="https://github.com/randomseed-io/bankster/blob/1.2.16/src/io/randomseed/bankster/scale.clj#L440">view source</a></div></div><div class="public anchor" id="var--.3Eint"><h3>->int</h3><h4 class="added">added in 1.0.0</h4><div class="usage"><code>(->int n)</code><code>(->int n rounding-mode)</code></div><div class="doc"><div class="markdown"><p>Converts to an int with optional rounding.</p>
</div></div><div class="src-link"><a href="https://github.com/randomseed-io/bankster/blob/1.2.16/src/io/randomseed/bankster/scale.clj#L428">view source</a></div></div><div class="public anchor" id="var--.3Elong"><h3>->long</h3><h4 class="added">added in 1.0.0</h4><div class="usage"><code>(->long n)</code><code>(->long n rounding-mode)</code></div><div class="doc"><div class="markdown"><p>Converts to a long with optional rounding.</p>
</div></div><div class="src-link"><a href="https://github.com/randomseed-io/bankster/blob/1.2.16/src/io/randomseed/bankster/scale.clj#L434">view source</a></div></div><div class="public anchor" id="var-div-math-context"><h3>div-math-context</h3><div class="usage"><code>(div-math-context a b)</code><code>(div-math-context a b rounding-mode)</code></div><div class="doc"><div class="markdown"><p>Returns the MathContext set to handle the possible precision for the operation of dividing two BigDecimal numbers. Optional rounding mode may be provided.</p>
</div></div><div class="src-link"><a href="https://github.com/randomseed-io/bankster/blob/1.2.16/src/io/randomseed/bankster/scale.clj#L100">view source</a></div></div><div class="public anchor" id="var-div-max-precision"><h3>div-max-precision</h3><h4 class="added">added in 1.0.0</h4><div class="usage"><code>(div-max-precision a b)</code></div><div class="doc"><div class="markdown"><p>Returns the maximum possible precision for the operation of dividing two BigDecimal numbers.</p>
</div></div><div class="src-link"><a href="https://github.com/randomseed-io/bankster/blob/1.2.16/src/io/randomseed/bankster/scale.clj#L91">view source</a></div></div><div class="public anchor" id="var-each"><h3>each</h3><h4 class="type">macro</h4><h4 class="added">added in 1.0.0</h4><div class="usage"><code>(each & body)</code></div><div class="doc"><div class="markdown"><p>Enables re-scaling on some consecutive operations which support it and sets the rounding mode for operations on scaled values. Internally sets <em>rescale-each</em> to true and <em>rounding-mode</em> to the given value.</p>
<p>Practically, in most cases it is better to use the with-rescaling macro which also sets rounding mode.</p>
</div></div><div class="src-link"><a href="https://github.com/randomseed-io/bankster/blob/1.2.16/src/io/randomseed/bankster/scale.clj#L624">view source</a></div></div><div class="public anchor" id="var-fractional"><h3>fractional</h3><h4 class="added">added in 1.0.0</h4><div class="usage"><code>(fractional n)</code><code>(fractional n scale)</code><code>(fractional n scale rounding-mode)</code></div><div class="doc"><div class="markdown"><p>Returns the fractional part of the given number, converted to decimal if required. Optional scale and rounding mode can be given. Makes use of <em>rounding-mode</em> if it’s set.</p>
</div></div><div class="src-link"><a href="https://github.com/randomseed-io/bankster/blob/1.2.16/src/io/randomseed/bankster/scale.clj#L403">view source</a></div></div><div class="public anchor" id="var-integer"><h3>integer</h3><h4 class="added">added in 1.0.0</h4><div class="usage"><code>(integer n)</code><code>(integer n scale)</code><code>(integer n scale rounding-mode)</code></div><div class="doc"><div class="markdown"><p>Returns the integer part of the given number, converted to decimal if required. Optional scale and rounding mode can be given. Makes use of <em>rounding-mode</em> if it’s set.</p>
</div></div><div class="src-link"><a href="https://github.com/randomseed-io/bankster/blob/1.2.16/src/io/randomseed/bankster/scale.clj#L391">view source</a></div></div><div class="public anchor" id="var-ROUND_CEILING"><h3>ROUND_CEILING</h3><h4 class="added">added in 1.0.0</h4><div class="usage"></div><div class="doc"><div class="markdown"><p>Rounding mode to round towards positive infinity.</p>
</div></div><div class="src-link"><a href="https://github.com/randomseed-io/bankster/blob/1.2.16/src/io/randomseed/bankster/scale.clj#L44">view source</a></div></div><div class="public anchor" id="var-ROUND_DOWN"><h3>ROUND_DOWN</h3><h4 class="added">added in 1.0.0</h4><div class="usage"></div><div class="doc"><div class="markdown"><p>Rounding mode to round towards zero.</p>
</div></div><div class="src-link"><a href="https://github.com/randomseed-io/bankster/blob/1.2.16/src/io/randomseed/bankster/scale.clj#L77">view source</a></div></div><div class="public anchor" id="var-ROUND_FLOOR"><h3>ROUND_FLOOR</h3><h4 class="added">added in 1.0.0</h4><div class="usage"></div><div class="doc"><div class="markdown"><p>Rounding mode to round towards negative infinity.</p>
</div></div><div class="src-link"><a href="https://github.com/randomseed-io/bankster/blob/1.2.16/src/io/randomseed/bankster/scale.clj#L49">view source</a></div></div><div class="public anchor" id="var-ROUND_HALF_DOWN"><h3>ROUND_HALF_DOWN</h3><h4 class="added">added in 1.0.0</h4><div class="usage"></div><div class="doc"><div class="markdown"><p>Rounding mode to round towards nearest neighbor, unless neighbors are equidistant, in which case round down.</p>
</div></div><div class="src-link"><a href="https://github.com/randomseed-io/bankster/blob/1.2.16/src/io/randomseed/bankster/scale.clj#L60">view source</a></div></div><div class="public anchor" id="var-ROUND_HALF_EVEN"><h3>ROUND_HALF_EVEN</h3><h4 class="added">added in 1.0.0</h4><div class="usage"></div><div class="doc"><div class="markdown"><p>Rounding mode to round towards nearest neighbor, unless neighbors are equidistant, in which case round towards the nearest one.</p>
</div></div><div class="src-link"><a href="https://github.com/randomseed-io/bankster/blob/1.2.16/src/io/randomseed/bankster/scale.clj#L66">view source</a></div></div><div class="public anchor" id="var-ROUND_HALF_UP"><h3>ROUND_HALF_UP</h3><h4 class="added">added in 1.0.0</h4><div class="usage"></div><div class="doc"><div class="markdown"><p>Rounding mode to round towards nearest neighbor, unless neighbors are equidistant, in which case round up.</p>
</div></div><div class="src-link"><a href="https://github.com/randomseed-io/bankster/blob/1.2.16/src/io/randomseed/bankster/scale.clj#L54">view source</a></div></div><div class="public anchor" id="var-ROUND_UNNECESSARY"><h3>ROUND_UNNECESSARY</h3><h4 class="added">added in 1.0.0</h4><div class="usage"></div><div class="doc"><div class="markdown"><p>Indication that no rounding is necessary.</p>
</div></div><div class="src-link"><a href="https://github.com/randomseed-io/bankster/blob/1.2.16/src/io/randomseed/bankster/scale.clj#L82">view source</a></div></div><div class="public anchor" id="var-ROUND_UP"><h3>ROUND_UP</h3><h4 class="added">added in 1.0.0</h4><div class="usage"></div><div class="doc"><div class="markdown"><p>Rounding mode to round away from zero.</p>
</div></div><div class="src-link"><a href="https://github.com/randomseed-io/bankster/blob/1.2.16/src/io/randomseed/bankster/scale.clj#L72">view source</a></div></div><div class="public anchor" id="var-Scalable"><h3>Scalable</h3><h4 class="type">protocol</h4><h4 class="added">added in 1.0.0</h4><div class="usage"></div><div class="doc"><div class="markdown"><p>The Scalable protocol describes values that can be scaled.</p>
</div></div><div class="members"><h4>members</h4><div class="inner"><div class="public anchor" id="var-amount"><h3>amount</h3><h4 class="added">added in 1.0.0</h4><div class="usage"><code>(amount num)</code><code>(amount num scale)</code><code>(amount num scale rounding-mode)</code></div><div class="doc"><div class="markdown"><p>Returns the amount of a scalable as a BigDecimal number. Some scalables may not be purely numeric so this function is to get the actual, calculable value out of them.</p>
</div></div></div><div class="public anchor" id="var-applied.3F"><h3>applied?</h3><h4 class="added">added in 1.0.0</h4><div class="usage"><code>(applied? num)</code></div><div class="doc"><div class="markdown"><p>Returns true if the value is of type which contains scaling information.</p>
</div></div></div><div class="public anchor" id="var-apply"><h3>apply</h3><div class="usage"><code>(apply num)</code><code>(apply num scale)</code><code>(apply num scale rounding-mode)</code></div><div class="doc"><div class="markdown"><p>Converts the given value to a scalable with or without changing its scale. For values that already are scalable it changes their scales if called with a second argument. The third argument, rounding-mode, must be present when downscaling and rounding is needed. For compound values (like monetary amounts) it will rescale the amount but will NOT update scale information of the unit (e.g. currency component).</p>
<p>When operating on Money objects and called with a single argument, it reapplies the nominal currency scale.</p>
</div></div></div><div class="public anchor" id="var-of"><h3>of</h3><h4 class="added">added in 1.0.0</h4><div class="usage"><code>(of num)</code></div><div class="doc"><div class="markdown"><p>Returns a scale. If the given value is not of type that scales (or is used to produce scaled types) it will be converted to such.</p>
</div></div></div><div class="public anchor" id="var-scalable.3F"><h3>scalable?</h3><h4 class="added">added in 1.0.0</h4><div class="usage"><code>(scalable? num)</code></div><div class="doc"><div class="markdown"><p>Returns true if the value can be converted to a scalable.</p>
</div></div></div></div></div><div class="src-link"><a href="https://github.com/randomseed-io/bankster/blob/1.2.16/src/io/randomseed/bankster/scale.clj#L114">view source</a></div></div><div class="public anchor" id="var-to-clojure-string"><h3>to-clojure-string</h3><h4 class="added">added in 1.1.0</h4><div class="usage"><code>(to-clojure-string n)</code></div><div class="doc"><div class="markdown"><p>Converts the amount to a plain string, adding the M suffix when needed.</p>
</div></div><div class="src-link"><a href="https://github.com/randomseed-io/bankster/blob/1.2.16/src/io/randomseed/bankster/scale.clj#L533">view source</a></div></div><div class="public anchor" id="var-to-clojure-symbol"><h3>to-clojure-symbol</h3><h4 class="added">added in 1.1.0</h4><div class="usage"><code>(to-clojure-symbol n)</code></div><div class="doc"><div class="markdown"><p>Converts the amount to a symbol, adding the M suffix when needed.</p>
</div></div><div class="src-link"><a href="https://github.com/randomseed-io/bankster/blob/1.2.16/src/io/randomseed/bankster/scale.clj#L541">view source</a></div></div><div class="public anchor" id="var-to-plain-string"><h3>to-plain-string</h3><h4 class="added">added in 1.0.7</h4><div class="usage"><code>(to-plain-string n)</code></div><div class="doc"><div class="markdown"><p>Converts the amount to a plain string.</p>
</div></div><div class="src-link"><a href="https://github.com/randomseed-io/bankster/blob/1.2.16/src/io/randomseed/bankster/scale.clj#L527">view source</a></div></div><div class="public anchor" id="var-to-symbol"><h3>to-symbol</h3><h4 class="added">added in 1.1.0</h4><div class="usage"><code>(to-symbol n)</code></div><div class="doc"><div class="markdown"><p>Converts the amount to a symbol.</p>
</div></div><div class="src-link"><a href="https://github.com/randomseed-io/bankster/blob/1.2.16/src/io/randomseed/bankster/scale.clj#L547">view source</a></div></div><div class="public anchor" id="var-unscaled-context"><h3>unscaled-context</h3><h4 class="added">added in 1.0.0</h4><div class="usage"></div><div class="doc"><div class="markdown"><p>MathContext indicating auto-scaling and no rounding.</p>
</div></div><div class="src-link"><a href="https://github.com/randomseed-io/bankster/blob/1.2.16/src/io/randomseed/bankster/scale.clj#L17">view source</a></div></div><div class="public anchor" id="var-with"><h3>with</h3><h4 class="added">added in 1.0.0</h4><div class="usage"><code>(with num)</code><code>(with num scale)</code><code>(with num scale rounding-mode)</code></div><div class="doc"><div class="markdown"><p>Alias for scale/apply.</p>
</div></div><div class="src-link"><a href="https://github.com/randomseed-io/bankster/blob/1.2.16/src/io/randomseed/bankster/scale.clj#L516">view source</a></div></div><div class="public anchor" id="var-with-rescaling"><h3>with-rescaling</h3><h4 class="type">macro</h4><h4 class="added">added in 1.0.0</h4><div class="usage"><code>(with-rescaling rounding-mode & body)</code></div><div class="doc"><div class="markdown"><p>Enables re-scaling on some consecutive operations which support it and sets the rounding mode for operations on scaled values. Internally sets <code>*each*</code> to true and <code>*rounding-mode*</code> to the given value.</p>
<p>The first argument should be a valid rounding (from <code>io.randomseed.bankster.scale</code> or <code>java.math.RoundingMode</code>) or one of the following:</p>
<p>CEILING - rounds towards positive infinity. DOWN - rounds towards zero. FLOOR - rounds towards negative infinity. HALF_DOWN - rounds towards nearest neighbor unless both neighbors are equidistant, in which case rounds down. HALF_EVEN - rounds towards the nearest neighbor unless both neighbors are equidistant, and if so, rounds towards the even. HALF_UP - rounds towards the nearest neighbor unless both neighbors are equidistant, and if so, rounds up. UP – rounds away from zero UNNECESSARY - asserts that the requested operation has an exact result, hence no rounding is necessary.</p>
</div></div><div class="src-link"><a href="https://github.com/randomseed-io/bankster/blob/1.2.16/src/io/randomseed/bankster/scale.clj#L601">view source</a></div></div><div class="public anchor" id="var-with-rounding"><h3>with-rounding</h3><h4 class="type">macro</h4><h4 class="added">added in 1.0.0</h4><div class="usage"><code>(with-rounding rounding-mode & body)</code></div><div class="doc"><div class="markdown"><p>Sets the rounding mode for operations on scaled values.</p>
<p>The first argument should be a valid rounding (from <code>io.randomseed.bankster.scale</code> or <code>java.math.RoundingMode</code>) or one of the following:</p>
<p>CEILING - rounds towards positive infinity. DOWN - rounds towards zero. FLOOR - rounds towards negative infinity. HALF_DOWN - rounds towards nearest neighbor unless both neighbors are equidistant, in which case rounds down. HALF_EVEN - rounds towards the nearest neighbor unless both neighbors are equidistant, and if so, rounds towards the even. HALF_UP - rounds towards the nearest neighbor unless both neighbors are equidistant, and if so, rounds up. UP – rounds away from zero UNNECESSARY - asserts that the requested operation has an exact result, hence no rounding is necessary.</p>
</div></div><div class="src-link"><a href="https://github.com/randomseed-io/bankster/blob/1.2.16/src/io/randomseed/bankster/scale.clj#L581">view source</a></div></div></div></body></html>