A
A
ahame2020-11-18 22:45:21
C++ / C#
ahame, 2020-11-18 22:45:21

How to rewrite this code?

How to rewrite this code with conditional statements:

int teqportion = msize*((i < msize % size)?msize / size + 1:msize / size);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mercury13, 2020-11-19
@ahame

I would suggest looking for an error in the code, there is a big suspicion - the first multiplier asks for size. Well, or dividing size % / msize - it's impossible to say. Well, or the condition will be not less, but more or more-equal. But we will work as is.

int v = msize / size;
if (i < msize % size) ++v;
int teqportion = msize * v;

Why do I suspect a mistake? Here it is very similar to severely broken rounding up or down to a multiple, depending on the condition.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question