C # math. Round () Achieves Chinese rounding
Math. Round () in C # does not use the "Rounding" method. In fact, in VB, VBScript, C #, J #, T-SQL in the round function are using banker's rounding (Banker algorithm), namely:Four Homes, six in five
Introduction
Today and test communication a percent calculation method encountered a problem, I used a strong cast in the stored procedure (32.678 as DECIMAL (5,1)) I think the method will only hold a decimal number, and my response to the test is
-- Round-- Returns a numeric expression rounded to the specified length or precision.---- Syntax-- Round (numeric_expression, length [, function])---- Parameter-- Numeric_expression---- Expression of exact or approximate numeric data type (except
Let's take a look at an example:
1: DECLARE @Value float
2: SET @Value = 12.1785
3: SELECT '12.1785' as ValueToRound, ROUND(@Value,3) as RoundedValue
4: SET @Value = 12.1745
5: SELECT '12.1745' as ValueToRound,ROUND(@Value,3) as
Round () Rounding out the js Banker algorithm, round banker
First, let's guess the result returned by round (0.825, 2,
First, SQL server Returns 0.83
The returned result of js is 0.83. The code is as follows:
Var B = 0.825; alert (Math. round (B * 1
C Tenth round of language: The function of the big secret"Learning goals"1. Definition of functions2. Use of functions3. Declaration of functions4. Formal parameters and arguments5. Return statement6. Invocation of functionsFunction: A function is a
Original: "C #" Excel Rounding function round, RoundUp, RoundDown C # versionIn C # I often miss the round in Excel, RoundUp, RoundDown These functions, the reason is the latter "Earth gas", compared to the rounding requirements of my small people,
ArticleDirectory
Step 1
Step 2
Step 3
This article from http://www.codeproject.com/KB/buttons/RoundButton_csharp.aspx
This sample code uses strates how to create a custom control, specifically a round button in C # With
In C # I often miss the round in Excel, RoundUp, RoundDown These functions, the reason is the latter "Earth gas", compared to the rounding requirements of my small people, what "banker rounding Method" Let the bankers to use it. Let's review some of
Yesterday (November 23), the battalion commander's Circle of Friends by the "Shang Tang Technology plan IPO and will set up research and Development center in the United States" brush screen. Even the media exposure, "the first year of commercial
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.