C#中的sizeof小数? [英] c# sizeof decimal?

查看:153
本文介绍了C#中的sizeof小数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不清楚的sizeof的十进制类型。请问字节大小通过精密的变化在SQL Server中?对于C#类型'小数'?精度变量

Unclear on the sizeof for decimal types. Does the size in bytes vary by precision as in sql server? Is the precision variable for the c# type 'decimal'?

我不想打开不安全的代码,只需拨打一个小数类型的sizeof。你会如何处理这个?

I don't want to turn on unsafe code to just call sizeof on a decimal type. How would you approach this?

推荐答案

正如其他人所说,小数始终是16个字节(128位)。 小数的精度始终是28/29位。这是一个浮点类型,不同于SQL的十进制键入。请参见我的文章就可以了的更多的细节。

As others have said, decimal is always 16 bytes (128 bits). The precision of decimal is always 28/29 digits. It's a floating point type, unlike SQL's DECIMAL type. See my article on it for more details.

这篇关于C#中的sizeof小数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆