Forum Academy Marketplace Showcase Pricing Features

Absolute difference between two numbers


I started writing a “need help” post but I found it out how to do writing :slight_smile:

I needed to check that the difference between two prices is higher than 0.01.
PriceA - PriceB > 0.01 gives a wrong result if PriceA < PriceB.

As there is no “:absolute” function, square can be used : PriceA - PriceB ^2 ^0.5
But (5.00 - 5.01)^2 ^0.5 gives something like 0.010001, which is > 0.01, because of the rounding in the calculation

so use a higher limit such as (PriceA - PriceB)^2 ^0.5 > 0.0101


I haven’t tried it myself yet, but check out the Mathjs plugin and use the abs() function.

1 Like

Haven’t thought about MathJS yet, thanks @Scott !