Control percentage

Hello everyone
actually I have two questions both are digital A and B. Indeed I want the amount entered to question A to be in the search of -15% and 15% variation on the validation condition in B. Example A.InRange(-15%, 15%)
but it doesn’t work
please help thank you

In C# the percentage sign is used to denote the arithmetic operator “remainder”. See here:

Hence, what you’ve written is nonsense in C# and the compiler correctly indicates that (although you didn’t show the exact error message).

The rest of your description I don’t understand, but I feel that there must be both questions mentioned in the condition, since they were both mentioned in the description.

Enfaite ce que je veux faire par la c’est encadrer un nombre qui va pas depaser + ou -15%
Exemple si je veux encadrer une variable comprise entre 4 et 8 je fais Var.InRange(4,8)

If you’re trying to limit response B within a range (-15%*A, 15%*A), you can do this:

B.InRange((A-A*(15/100)), (A+A*(15/100)))

1 Like

Simplify:

(A/B).InRange(0.85, 1.15)

Note that when B is zero, A/B generates an exception (division by zero) and this is treated as FALSE, which is equivalent to not being within the range [0.85,1.15].

2 Likes