"Greater than" and "Less than" for numbers less than 1

I have a quality control script that examines a large spreadsheet for values out of specification. It is not working for certain number types that seem to be decimals. When I check with the following simplified script it works for integers but not for values less than 1. For example:

Value1 = 10 Value2 = 20. Result = 10 - 20 (-10)
If Result <0 type “Neg”

This works fine. If however the values are
Value1 = 0.1 Value2 = 0.2 then the “If” condition does not execute and even though I can see the calculation has worked the “Neg” does not get typed.

Is this a known bug? Below is the execution path for the fraction numbers.

Hi @Bonnero, I just tried a similar recording, and it worked fine.
Could you share your script to test it?

Hi Alesia,

I simplified even further and attached the script. When I set Val1 = 1 and Val2 = 2 the the result is negative and I get the expected output from the If condition loop. When I set Val1 = 0.1 and Val2 = 0.2 I get the wrong outcome. Attached screenshot and file.

Untitled-33.rar (1.2 KB)

Hi Alesia,

I just upgraded to 2.04 and the above script works now. However, the version that reads from Excel still does not. Attached the script and info from that version:

Untitled-32.rar (2.7 KB)

One final observation:
The comparison is rounding to the nearest whole number even when the exact sum has a decimal part.
See attached script and the outputs into notepad.

The sum is evaluating to -1.0 even though it is exactly -1.1 Is this expected behaviour?

You are right, only the integer part is compared.
I had a bad example before when the difference was more than 1.

This is a bug, we have created a task to fix it.

Thank you.
I’ll keep an eye on the bug fix installation notes and park that project for now.

1 Like

Hi Alesia,

I see that this bug is still present in 2.05. Do you have a timeline for it to be fixed?

Reminder - the comparison is only on the integer part so the logic fails when comparing non-integer numbers.


While we are working for a bug fix here is a custom script that will do the job

// This script compares two numbers as input, var1 and Var2
// and returns a ‘result’ with three possible values:
// “Less” if var1 is LESS than var2
// “Equal” if var1 is EQUAL to var2
// “Greater” if var1 is GREATER than var2

input = [‘var1’, ‘var2’],
output = ‘result’

def customScript() {

def x = RNumber.of(var1)
def y = RNumber.of(var2)

if( x.compareTo(y) < 0 ){
def result = RString.of(“Less”)

else if( x.compareTo(y) == 0 ){
def result = RString.of(“Equal”)

else if ( x.compareTo(y) > 0 ){
def result = RString.of(“Greater”)


1 Like

Thanks a lot for the script Owen :+1:

The fix is taking longer than we expected, there is no fast solution for this. I will post here as soon as we have an ETA for it.

in if condition
when I compare two decimal numbers the result is wrong.

for example.
number1 = 0.27, number2 = 0.25
if number1 = number2, the system thinks they are the same.

number3 = 2, number4 = 3
if number3 = number4, the system thinks they are different.

1 Like

@yangyanz thank you for reporting. We have fixed this issue for the new build that will be released next week.

@yangyanz @Bonnero this bug has been fixed in version 2.2.