Rounding to Specific decimals

Hi guys,
i need to round Room Area to a certain Scheme
0.00 to 0:15 = 0.1
0:16 to 0:65 = 0.5
0.66 to 0.99 = +1

I used String then extract the decimals but it sounds like i could do much better, any ideas?

Something like this :grinning:

1 Like

looks good except that my input is a list of list and i like to keep the structure :slight_smile:
Am i asking too much

input = IN[0]
result = []

for x in input:
	numbers = []
	for y in x:

OUT = result

I get a weird result at [1][3]

Try using the Math.Round node to reduce the decimal places to say 5 digits, then try again.

It is because you cannot divide by zero :slight_smile:

1 Like

Wasn’t this value to be 0.1?

No it 0 but i didn’t think it would matter… turns out i was wrong lol

The Modulo operator could save you some nodes and unneeded python jumps here:

EndFragment:00000846 FullNumb =

Remainders =

Remainders <= 0.15?
    Remainders <= 0.65?

Note that I didn’t bother with the exception handling for ‘range cannot be specified’ here.

You could call the full number function and remainder test in line with the if statement if you were so inclined.


Very nice @jacob.small :+1:

1 Like

Ok… this is damn sweet :slight_smile:

Thanks a million guys

1 Like

Glad I could help. :slight_smile: