Topic
• Latest Post - ‏2012-12-11T13:46:37Z by SystemAdmin
1883 Posts

# Pinned topic Convert negatives values to 0

‏2012-12-09T22:52:25Z |
Hey

I don't have a lot of experience using OPC CPLEX. I've just started to use it in the university few months ago. I'm duing an exercise and I need some help.

I have this vector: int RetrasosBultos with negative and positives values. And I want to convert the negatives values to 0.

How can I do that? I supose it must be easy, but I don`t know...

Thanks
Updated on 2012-12-11T13:46:37Z at 2012-12-11T13:46:37Z by SystemAdmin
1883 Posts

#### Re: Convert negatives values to 0

‏2012-12-11T13:46:37Z
Say that you have:

```int a[i in I] = ...
```

then you could convert the negative values to 0 using the one line if syntax:

```int b[i in I] = a[i] > 0 ? a[i] : 0;
```

The meaning of the instruction is simply: "if a[i] is greater than 0 then b[i] = a[i] else b[i] = 0".

Regards,
Stefano
Updated on 2014-03-26T05:52:11Z at 2014-03-26T05:52:11Z by iron-man