C # rounding rounding Math

C # Math rounding of 
the main uses a data Class System Namespace in Math, calls his method. 

C # Detailed ceiling function used: 
. 1 , Math.Round is " round to nearest " , when the rounding is to the 5 " rounding " different (that is even), such as: 
Math.Round ( 0.5 , 0 ) = 0     
the Math .Round ( for 1.5 , 0 ) = 2     
Math.Round ( 2.5 , 0 ) = 2     
Math.Round ( 3.5 of , 0 ) = . 4  

2 , Math.Truncate calculates the integer part of the double-precision floating point, i.e. direct rounded, such as: 
Math.Truncate ( - 123.55 ) = - 123 ,
Math.Truncate ( 123.55 ) = 123    

. 3 , top plate Math.Ceiling take values, i.e. rounded up, with " rounded " irrelevant. 
Math.Ceiling ( . 1 ) = . 1 
Math.Ceiling ( 1.1 ) = 2 
Math.Ceiling ( for 1.5 ) = 2 
Math.Ceiling ( 3.1 ) = . 4  

. 4 , Math.Floor take the floor value, i.e., rounded down, and " rounding " unrelated. 
Math.Floor ( . 1 ) = . 1 
Math.Floor ( 1.1 ) = . 1 
Math.Floor ( for 1.5 ) = . 1 
Math.Floor ( 3.9) = 3 
   
take the top plate and the floor value of the value, the " rounding " has nothing to do. In fact, the results Floor ( int ) the same, and therefore also write Math.Floor (( Double ) 2 / . 3 + 0.5 )
 int A = . 5 ; int B = 2 ; = lbl.Text Convert.ToString (Math.Ceiling ( ( Double ) A / ( Double ) B));

 

Guess you like

Origin www.cnblogs.com/ruralcraftsman/p/11365417.html