In dealing with some of the data, we want to be able to use the "rounding" method, but C # uses the "four six into 50% pairs" method, such as the following example, is the "four six into 50% pairs" results obtained:Double D1 = Math.Round (1.25, 1);//
The simple floating-point number types in Java float and double are not capable of operation. It's not just Java, it's also a problem in many other programming languages.What will we see if we compile and run the following program?public class Test {
This is a creation in
Article, where the information may have evolved or changed.
Four homes six into 50% pairs is a more accurate and scientific method of counting retention, which is a kind of digital revision rule, aka Banker rounding method. It
Four homes six into 50% pairsHttp://baike.baidu.com/view/1245064.htm?fr=aladdinFour homes six in 50% pairs is a more accurate and scientific method of counting retention, which is a kind of digital revision rule.For a number of approximate numbers
Math.Round () in C # to make Chinese-style roundingMath.Round () in C # is not a "rounding" method used. In fact, in VB, VBScript, C #, J #, T-SQL round functions are used banker ' s rounding (banker algorithm), namely: four six into the five to
Original: C # in Math.Round () to achieve Chinese-style roundingMath.Round () in C # to make Chinese-style roundingMath.Round () in C # is not a "rounding" method used. In fact, in VB, VBScript, C #, J #, T-SQL round functions are used banker ' s
Cases:VarI, J:integer;BeginI: = Round (1.5); I equals 2J: = Round (2.5); J equals 2.EndThe answers used in Delphi with the round function are sometimes not the same as we expected: The four-house six into the five-left double. That is, when the
VC + + is using the Round half away from zero
GCC is using the Round half to even which is also known as banker ' s rounding.
Nearest integer function in computer science, the Nearest integer function of real number x denoted variously by
As the original text has been introduced very well, now is only a few translations and a small supplement.
Example
Copy Code code as follows:
Demo
Format: 9999.99 (range is 0-9999.99) (dynamically modify Alt
Since the original article has already been quite well introduced, it is only some translation and a small supplement.
Example
CopyCode The Code is as follows:
demo
Format: 9999.99 (range: 0-9999.99) (dynamically modify the alt attribute):
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.