# Trigger Condition Math Precision

**URL:** <https://forum.opensearch.org/t/trigger-condition-math-precision/12093>\
**Category:** Alerting\
**Tags:** troubleshoot\
**Created:** [January 12, 2023, 9:41pm UTC](https://forum.opensearch.org/t/trigger-condition-math-precision/12093 "2023-01-12T21:41:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dgraapArrived](https://avatars.discourse-cdn.com/v4/letter/d/bcef8e/32.png) [@dgraapArrived](https://forum.opensearch.org/u/dgraapArrived)\
**Post date:** [January 12, 2023, 9:41pm UTC](https://forum.opensearch.org/t/trigger-condition-math-precision/12093/1 "2023-01-12T21:41:15Z")

</div>

**Versions** (relevant - OpenSearch/Dashboard/Server OS/Browser):  
Opensearch v1.1.0

**Describe the issue** :

I have an extraction query response with values “Error\_count”: 10 and “Success\_count”: 8858, but the following evaluates to `true`:

ctx.results[0].aggregations.Error\_count / ctx.results[0].aggregations.Success\_count == 0.0

How can I properly cast these numbers to get the right precision? Or is there a division function built-in?

ETA: adding `.floatValue()` ([Value (Groovy 4.0.7)](https://docs.groovy-lang.org/latest/html/api/org/apache/groovy/json/internal/Value.html#floatValue())) to both of my variables appears to have done the trick, based on some googling & seeing “Painless is the default OpenSearch scripting language and has a syntax similar to Groovy.” here: [Monitors - OpenSearch documentation](https://opensearch.org/docs/latest/monitoring-plugins/alerting/monitors/#extraction-query)

Now the following evaluates to `false`:  
ctx.results[0].aggregations.2.buckets.Error.doc\_count.floatValue() / ctx.results[0].aggregations.2.buckets.Success.doc\_count.floatValue() \> 0.002

and this evaluates to `true`:  
ctx.results[0].aggregations.2.buckets.Error.doc\_count.floatValue() / ctx.results[0].aggregations.2.buckets.Success.doc\_count.floatValue() \> 0.001
