User Tools

Site Tools


code:round

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

code:round [2015/11/19 15:19] (current)
michfiel created
Line 1: Line 1:
 +==== round ====
 +
 +http://​www.cplusplus.com/​
 +\\
 +round() Returns the integral value that is nearest to x, with halfway cases rounded away from zero \\
 +floor() Rounds x downward, returning the largest integral value that is not greater than x \\
 +ceil() Rounds x upward, returning the smallest integral value that is not less than x \\
 +trunc() The nearest integral value that is not larger in magnitude than x (as a floating-point value) \\
 +\\
 +
 +^  value^ ​ round^ ​ floor^ ​ ceil^  trunc^
 +|  2.3|  2.0|  2.0|  3.0|  2.0|
 +|  3.8|  4.0|  3.0|  4.0|  3.0|
 +|  5.5|  6.0|  5.0|  6.0|  5.0|
 +|  -2.3|  -2.0|  -3.0|  -2.0|  -2.0| 
 +|  -3.8|  -4.0|  -4.0|  -3.0|  -3.0|
 +|  -5.5|  -6.0|  -6.0|  -5.0|  -5.0|
 +
 +
 +  * rint() Rounds x to an integral value, using the rounding direction specified by fegetround
 +  * near() The value of x rounded to a nearby integral (as a floating-point value)
 +
  
code/round.txt ยท Last modified: 2015/11/19 15:19 by michfiel