<p>I think you're not using the correct comparison operators. Make sure you import <code>PlutusTx.Prelude</code> and use <code>==</code> function from there, like described here:</p>
<p><a href="https://cardano.stackexchange.com/a/8323/5085">https://cardano.stackexchange.com/a/8323/5085</a></p>

CC BY-SA 4.0
2022-06-06T08:55:39.450Z
2022-06-06T08:55:39.450Z
Will
<p>In the validator, I have defined:</p>
<pre><code>txInfo :: TxInfo
txInfo = scriptContextTxInfo ctx

feePaid :: Integer
feePaid = Ada.getLovelace (Ada.fromValue (txInfoFee txInfo))
</code></pre>
<p>the strange thing is, when I do:</p>
<pre><code>traceIfFalse &quot;fee test&quot; (feePaid &gt;= 0)
</code></pre>
<p>, it evaluates to True, but</p>
<pre><code>traceIfFalse &quot;fee test&quot; (feePaid == 0)
</code></pre>
<p>and</p>
<pre><code>traceIfFalse &quot;fee test&quot; (feePaid &gt; 0)
</code></pre>
<p>evaluates to False! How is this possible? Am I doing something wrong?</p>
<p>The very same thing happens when using Plutus.V1.Ledger.Contexts functions.</p>
<p>For example valueProduced (of ADA, using valueOf, so getting Integer) - valueSpent (same, Integer) equates to true if using &gt;= or &lt;= operator, but is neither &gt;, &lt; or ==.</p>
<p>Evaluating using Emulator Trace.</p>
<p>valueProduced, valueSpent example:</p>
<pre><code>test :: TxInfo -&gt; Order -&gt; Integer
test info ord = subtractInteger (valueOf (valueProduced info) (quoteAssetSymbol ord) (quoteAssetName ord)) (valueOf (valueSpent info) (quoteAssetSymbol ord) (quoteAssetName ord))
</code></pre>
<p>Order has quoteAssetSymbol which is of type CurrencySymbol and is ADA (&quot;&quot;), quoteAssetSymbol is of type TokenName, and is also ADA (&quot;&quot;).</p>
<p>Tried using greaterThanEqualsInteger, equalsInteger, etc.. Same result</p>

<plutus>
Are on-chain validator Integer comparing functions working correctly?
# Are on-chain validator Integer comparing functions working correctly?

(Asked by: username_0 on 2021-11-24)

In the validator, I have defined:

```
txInfo :: TxInfo
txInfo = scriptContextTxInfo ctx

feePaid :: Integer
feePaid = Ada.getLovelace (Ada.fromValue (txInfoFee txInfo))

```

the strange thing is, when I do:

```
traceIfFalse "fee test" (feePaid >= 0)

```

, it evaluates to True, but

```
traceIfFalse "fee test" (feePaid == 0)

```

and

```
traceIfFalse "fee test" (feePaid > 0)

```

evaluates to False! How is this possible? Am I doing something wrong?

The very same thing happens when using Plutus.V1.Ledger.Contexts functions.

For example valueProduced (of ADA, using valueOf, so getting Integer) - valueSpent (same, Integer) equates to true if using >= or <= operator, but is neither >, < or ==.

Evaluating using Emulator Trace.

valueProduced, valueSpent example:

```
test :: TxInfo -> Order -> Integer
test info ord = subtractInteger (valueOf (valueProduced info) (quoteAssetSymbol ord) (quoteAssetName ord)) (valueOf (valueSpent info) (quoteAssetSymbol ord) (quoteAssetName ord))

```

Order has quoteAssetSymbol which is of type CurrencySymbol and is ADA (""), quoteAssetSymbol is of type TokenName, and is also ADA ("").

Tried using greaterThanEqualsInteger, equalsInteger, etc.. Same result

**Tags:** plutus


---

## 1 answers

### Answer by username_1 on 2022-06-06. Score: 1

I think you're not using the correct comparison operators. Make sure you import `PlutusTx.Prelude` and use `==` function from there, like described here:

<https://cardano.stackexchange.com/a/8323/5085>


---

