Tuesday, November 17, 2009

How to represent a range like 0 - 10000 as a mathematical constant?

I am a student of C++ programming and I need to know how to represent a variable number range like 0 - 10000 as a mathematical constant so I can use it in a (switch case) selection structure. I know that this can be done by using anther variable and also by using (switch case if) selection structure.

How to represent a range like 0 - 10000 as a mathematical constant?
abs(10000-x) + abs(x) will equal 10000 if and only if:


0 ≤ x ≤ 10000


(it will equal abs(2x-10000) otherwise)


No comments:

Post a Comment