Home Database Mysql Tutorial C#和sqlserver数字数据类型学习

C#和sqlserver数字数据类型学习

Jun 07, 2016 pm 03:41 PM
sqlserver study number data type

C#数字类型的数据包括decimal, double和 float。以前学过现在忘得都差不多了,现在简单的复习一下。 根据MSDN的解释, decimal类型是128位的浮点数,数据范围是1.010 28 to 7.910 28 ,精度在28-29位有效数字,在一个数字后面加m或M代表它是decimal类型。 do

C#数字类型的数据包括decimal, double和 float。以前学过现在忘得都差不多了,现在简单的复习一下。

 

根据MSDN的解释,

decimal类型是128位的浮点数,数据范围是±1.0 × 10−28 to ±7.9 × 1028,精度在28-29位有效数字,在一个数字后面加m或M代表它是decimal类型。

double类型是64位的浮点数,数据范围是±5.0 × 10−324 to ±1.7 × 10308,精度在15-16位有效数字,在一个数字后面加d或D代表它是double类型。正常的带小数点的数字都会默认为double类型,如果想让一个整形作为double类型处理,就在后面加上d或D. 相比之下,decimal类型比double类型精度高,但是范围相对小一些。

float类型是32位的浮点数,数据范围是±1.5 × 10−45 to ±3.4 × 1038,精度是7位,在一个数字后面加f或F代表它是float类型。可以看出,它比decimal类型精度小很多,但是范围要大一些。

 

对于sqlserver里的money类型,它8位的,数据范围在-922,337,203,685,477.5808 到922,337,203,685,477.5807之间得数据类型,

smallmoney则是4位的在- 214,748.3648 到214,748.3647之间。

 

在sqlserver中还有数字类型,就是decimal和numeric,它们是相同的,具有可以指定的精度(有效数字位数)和规格,最大范围是- 10^38 +1 到10^38 - 1。

下表表示了精度和存储位数的关系:

精度 存储位数 

1 - 9

5

10-19

9

20-28

13

29-38

17

 

 

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to import mdf file into sqlserver How to import mdf file into sqlserver Apr 08, 2024 am 11:41 AM

How to import mdf file into sqlserver

What to do if the sqlserver service cannot be started What to do if the sqlserver service cannot be started Apr 05, 2024 pm 10:00 PM

What to do if the sqlserver service cannot be started

How to recover accidentally deleted database in sqlserver How to recover accidentally deleted database in sqlserver Apr 05, 2024 pm 10:39 PM

How to recover accidentally deleted database in sqlserver

The vitality of super intelligence awakens! But with the arrival of self-updating AI, mothers no longer have to worry about data bottlenecks The vitality of super intelligence awakens! But with the arrival of self-updating AI, mothers no longer have to worry about data bottlenecks Apr 29, 2024 pm 06:55 PM

The vitality of super intelligence awakens! But with the arrival of self-updating AI, mothers no longer have to worry about data bottlenecks

How to delete sqlserver if the installation fails? How to delete sqlserver if the installation fails? Apr 05, 2024 pm 11:27 PM

How to delete sqlserver if the installation fails?

Slow Cellular Data Internet Speeds on iPhone: Fixes Slow Cellular Data Internet Speeds on iPhone: Fixes May 03, 2024 pm 09:01 PM

Slow Cellular Data Internet Speeds on iPhone: Fixes

How to change sqlserver English installation to Chinese How to change sqlserver English installation to Chinese Apr 05, 2024 pm 10:21 PM

How to change sqlserver English installation to Chinese

The U.S. Air Force showcases its first AI fighter jet with high profile! The minister personally conducted the test drive without interfering during the whole process, and 100,000 lines of code were tested for 21 times. The U.S. Air Force showcases its first AI fighter jet with high profile! The minister personally conducted the test drive without interfering during the whole process, and 100,000 lines of code were tested for 21 times. May 07, 2024 pm 05:00 PM

The U.S. Air Force showcases its first AI fighter jet with high profile! The minister personally conducted the test drive without interfering during the whole process, and 100,000 lines of code were tested for 21 times.

See all articles