UDT Parameters Division

in accord with that: https://docs.inductiveautomation.com/display/DOC81/UDT+Parameters
/ Division. Dividing the first number by the second number. {BaseAddress/2} but a result is a double number like “0.1” i try to format: {BaseAddress/2|0} but the result is a rnd no a floor so how to have a integer i try many ways but I’m lost

What BaseAddress value gives you a result of “0.1”?
Where is the result visible? (I have never used this feature so I do not know.)

I just copy and past from the manual in my was {No/16}:
No is an integer…
but if “No” is 2 comes the result is 0.125
if I change to {No/16|0} comes 0 (right) but until 8 after the result is 1 … I’m confused about how to do … I miss something …

You can see the result in the instance of the UDT

Looks like you are not the first to have this question, looks like it can be fixed with formatting.

Just tried it out, it works, you were close:

{BaseAddress/2|#}

I’ll try tomorrow morning… anvirtual :beers: for your help …

1 Like

you gave me false hope :frowning:

I tried with # but the result is the same

{x/16|#}

with x from 0 to 8 the result is 0
with x> 8 the result is 1

so… how to do it?

Tip: use the </> code formatting button when pasting blocks of code. It preserves indents and applies syntax highlighting. You can use `backticks` for inline code. It makes it much clearer where code starts and ends.

1 Like

Not sure what to tell you, works as expected for me.

Edit:
Actually you are right, it doesn’t. Part of me thinks this may be a bug but the other part is saying when you divide 9 by 16 the answer is a float.

I understood but for me this is crazy … I’ll change my udt and I pass 2 parameters but is not the same: a lot of work instead just a wizard udt :frowning:

… frustrate mode on
what I love about ignition is the back end but if work casually I start to look around …

I like when someone explains to me how to use a tool/chat/software/calculator/etc because after 35 years of software engineering I still want to learn. But I prefer first solve a problem and after explain how to speak better: plants need to run (and produce money)
…frustrate mode off

It may actually be a bug, hopefully we get an IA person to comment. This is a super niche thing though, It only applies to UDT parameters being used in an opc path. You could probably do what you need to in an expression tag with the use of floor() and bind that tag to the opc path.

yeah … the idea of the expression tag and floor is nice just I don’t understand how to bind that in the OPC path …

Will something like this work to get the floor:

{(x)/16-(x%16)/16|#}

2 Likes

The result of the operation is a number between 0 and 1.

When the BaseAddress >= 8 then the result is >= 0.5, which when rounded becomes 1 any thing < 8 is < 0.5 and so is rounded to 0.

I don’t think this is a bug, I think it is the intended behavior, it just isn’t explained that the / is true division, not integer division. There may be some argument to a bug when the formatting is applied, as I would think it would just truncate instead of rounding.

@philip’s formula will yield a floor of the dividend.

Look like work,
just is a crazy math way for a simple question :slight_smile:

Thanks, Philip

for me is crazy … what is the sense of having the possibility of floating numbers in a place where 99% is an index.
but I’m from the old guard and the plant programming was just 2 + 2