c# - How does DoubleUtil.DoubleToInt(double val) work? -


the ms.internal.doubleutil-class contains function

public static int doubletoint(double val) {     return (0 < val) ? (int)(val + 0.5) : (int)(val - 0.5); } 

i wonder why 'converts' val integer?

the cast double int takes floor, adding .5 (or subtracting .5 if negative) means 1.6 returns 2, while 1.4 return 1.


Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

jquery - How would i go about shortening this code? And to cancel the previous click on click of new section? -