<p><code>Ada</code> is an integer under the hood and <a href="https://alpha.marlowe.iohkdev.io/doc/haddock/plutus-tx/html/PlutusTx-Prelude.html#v:divide" rel="nofollow noreferrer"><code>divide</code> rounds down</a>.</p>
<p>So, if <code>amount</code> is <code>5</code>, <code>half</code> would be <code>2</code> and <code>(amount - half)</code> would be <code>3</code> (totaling to <code>5</code>).</p>

CC BY-SA 4.0
2021-08-26T22:33:03.330Z
2021-08-26T22:33:03.330Z
Mitchell Turner
<p>re: <a href="https://plutus.readthedocs.io/en/latest/plutus/tutorials/basic-apps.html" rel="nofollow noreferrer">https://plutus.readthedocs.io/en/latest/plutus/tutorials/basic-apps.html</a></p>
<p>Given that the explanation is &quot;&quot;The validator checks that the transaction, represented by scriptContextTxInfo, pays half the specified amount to each recipient.&quot;, why does the code not simply use <code>==half</code> in both cases?</p>
<pre><code>validateSplit :: SplitData -&gt; () -&gt; ScriptContext -&gt; Bool
validateSplit SplitData{recipient1, recipient2, amount} _ ScriptContext{scriptContextTxInfo} =
    let half = Ada.divide amount 2 in
    Ada.fromValue (valuePaidTo scriptContextTxInfo recipient1) &gt;= half &amp;&amp;
    Ada.fromValue (valuePaidTo scriptContextTxInfo recipient2) &gt;= (amount - half)```
</code></pre>

<plutus>
What am I missing here- simple Plutus code from tutorial?
# What am I missing here- simple Plutus code from tutorial?

(Asked by: username_0 on 2021-08-26)

re: https://plutus.readthedocs.io/en/latest/plutus/tutorials/basic-apps.html
Given that the explanation is ""The validator checks that the transaction, represented by scriptContextTxInfo, pays half the specified amount to each recipient.", why does the code not simply use ==half in both cases?
validateSplit :: SplitData -> () -> ScriptContext -> Bool
validateSplit SplitData{recipient1, recipient2, amount} _ ScriptContext{scriptContextTxInfo} =
    let half = Ada.divide amount 2 in
    Ada.fromValue (valuePaidTo scriptContextTxInfo recipient1) >= half &&
    Ada.fromValue (valuePaidTo scriptContextTxInfo recipient2) >= (amount - half)```

**Tags:** plutus

---

## 1 answers

### Answer by username_1 on 2021-08-26. Score: 2

`Ada` is an integer under the hood and [`divide` rounds down](https://alpha.marlowe.iohkdev.io/doc/haddock/plutus-tx/html/PlutusTx-Prelude.html#v:divide).

So, if `amount` is `5`, `half` would be `2` and `(amount - half)` would be `3` (totaling to `5`).


---

