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 -

image - ClassNotFoundException when add a prebuilt apk into system.img in android -