请教转换float小数点后精度的函数C#和sql select round(YourField,4) from YourTable where YourWhere不可以吗? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 ROUND返回数字表达式并四舍五入为指定的长度或精度。语法ROUND ( numeric_expression , length [ , function ] ) 参数numeric_expression精确数字或近似数字数据类型类别的表达式(bit 数据类型除外)。length是 numeric_expression 将要四舍五入的精度。length 必须是 tinyint、smallint 或int。当 length 为正数时,numeric_expression 四舍五入为 length 所指定的小数位数。当 length 为负数时,numeric_expression 则按 length 所指定的在小数点的左边四舍五入。function是要执行的操作类型。function 必须是 tinyint、smallint 或 int。如果省略 function 或 function 的值为 0(默认),numeric_expression 将四舍五入。当指定 0 以外的值时,将截断 numeric_expression。返回类型返回与 numeric_expression 相同的类型。 Math.Round 方法 (Double, Int32)返回具有指定精度、最接近指定值的数。[Visual Basic]Overloads Public Shared Function Round( _ ByVal value As Double, _ ByVal digits As Integer _) As Double[C#]public static double Round( double value, int digits);[C++]public: static double Round( double value, int digits);[JScript]public static function Round( value : double, digits : int) : double;参数value 要舍入的双精度浮点数。 digits 返回值中的有效小数位数(精度)。 返回值精度等于 digits 的、最接近 value 的数字。如果 value 位于两个数字的中间,其中一个为偶数,另一个为奇数,则返回偶数。如果 value 的精度小于 digits,则返回 value 而不做更改。备注digits 参数指定返回值的有效小数位数,其范围在 0 到 15 之间。如果 digits 为零,则返回一个整数。此方法的行为遵循 IEEE 标准 754 的第 4 节。这种舍入有时称为就近舍入或银行家舍入。如果 digits 为零,则这种舍入有时称为“向零舍入”。示例[Visual Basic, C#, C++] 下面的代码演示就近舍入。[Visual Basic] Math.Round(3.44, 1) 'Returns 3.4.Math.Round(3.45, 1) 'Returns 3.4.Math.Round(3.46, 1) 'Returns 3.5.[C#] Math.Round(3.44, 1); //Returns 3.4.Math.Round(3.45, 1); //Returns 3.4.Math.Round(3.46, 1); //Returns 3.5. Round()是在SQL中截取Math.Round()是在C#中或VB.net 正则表达式 给高分 gridview的更新有误,还是旧值,求助 【下载问题】用二进制流方式下载文件后,文件名被自动修改,例如:"001.txt"会被修改为"001[1].txt",详情见内 DateTime.Now.Ticks ?? 服务器当机问题(急) 《〈〈〈treeview的问题〉〉〉》》 如何设定自定义控件的加载顺序? 如何实现下拉框中操作表? 如何将某一用户从论坛中踢出去 vs 2003,如何读取资源文件? 概念性问题,敬请班组和熟知.net的高手....... 如何将Hashtable绑定于DropDownList控件?
返回数字表达式并四舍五入为指定的长度或精度。语法
ROUND ( numeric_expression , length [ , function ] ) 参数
numeric_expression精确数字或近似数字数据类型类别的表达式(bit 数据类型除外)。length是 numeric_expression 将要四舍五入的精度。length 必须是 tinyint、smallint 或int。当 length 为正数时,numeric_expression 四舍五入为 length 所指定的小数位数。当 length 为负数时,numeric_expression 则按 length 所指定的在小数点的左边四舍五入。function是要执行的操作类型。function 必须是 tinyint、smallint 或 int。如果省略 function 或 function 的值为 0(默认),numeric_expression 将四舍五入。当指定 0 以外的值时,将截断 numeric_expression。返回类型
返回与 numeric_expression 相同的类型。
返回具有指定精度、最接近指定值的数。[Visual Basic]
Overloads Public Shared Function Round( _
ByVal value As Double, _
ByVal digits As Integer _
) As Double
[C#]
public static double Round(
double value,
int digits
);
[C++]
public: static double Round(
double value,
int digits
);
[JScript]
public static function Round(
value : double,
digits : int
) : double;
参数
value
要舍入的双精度浮点数。
digits
返回值中的有效小数位数(精度)。
返回值
精度等于 digits 的、最接近 value 的数字。如果 value 位于两个数字的中间,其中一个为偶数,另一个为奇数,则返回偶数。如果 value 的精度小于 digits,则返回 value 而不做更改。备注
digits 参数指定返回值的有效小数位数,其范围在 0 到 15 之间。如果 digits 为零,则返回一个整数。此方法的行为遵循 IEEE 标准 754 的第 4 节。这种舍入有时称为就近舍入或银行家舍入。如果 digits 为零,则这种舍入有时称为“向零舍入”。示例
[Visual Basic, C#, C++] 下面的代码演示就近舍入。[Visual Basic]
Math.Round(3.44, 1) 'Returns 3.4.
Math.Round(3.45, 1) 'Returns 3.4.
Math.Round(3.46, 1) 'Returns 3.5.
[C#]
Math.Round(3.44, 1); //Returns 3.4.
Math.Round(3.45, 1); //Returns 3.4.
Math.Round(3.46, 1); //Returns 3.5.
Math.Round()是在C#中或VB.net