I have two integers ( input & output )
when input >= 1 and <= 100000 , output will 20
when input >= 100001 and <= 200000 , output will 30
when input >= 200001 and <= 300000 , output will 40
when input >= 300001 and <= 400000 , output will 50
when input >= 400001 and <= 500000 , output will 60
...
...
and so on.
Max range of input is unlimited
How can I manage it in C#
output = (ceil(input/100000) +1)*10
The ceil function basically rounds above a float to an integer.
Simple arithemtic along with integer division should do the trick
var output = (input / 100000) * 10 + 20;
If the input
is a floating point or decimal already then use Math.Floor
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.