我可以使用什么数据类型来表示C#中的数字(20,6) [英] What datatype I can use for representing number(20, 6) in C#

查看:159
本文介绍了我可以使用什么数据类型来表示C#中的数字(20,6)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

< pre lang =text> 

我可以用什么数据类型来表示c#
$ b $中的数字(20,6) b

我尝试了什么:



我尝试过双数据类型但是列值没有显示正确输入的数字总数超过16(包括小数点)

解决方案

您可以创建您自己的数据类型。查看数据结构。



当你使用C#时,你会发现它们非常像一个类,除非默认情况下是公开的。



事实证明,如果你研究一些图形命名空间,你会发现它们有数据点的类型。这也是你正在寻找的东西。



学习制作自己的东西是非常值得的!


十进制数据类型可能更适合您。它是一个固定点(与浮点相对)数据类型。虽然,您可能无法存储任意位数的数字,但十进制类型有其自己的限制。



您可以在此处阅读有关十进制类型的更多信息:

MSDN:十进制结构 [ ^ ]

<pre lang="text">

what datatype I can use for representing number(20,6) in c#

What I have tried:

I have tried with double datatype but the column value is not displaying properly with the total no of digits entered is more than 16 (including decimal point)

解决方案

You can create your own datatype. Look into data structures.

As you're using C#, you'll find they're very much like a class, except, by default, things are public.

As it turns out, if you look into some of the graphics namespaces you'll find they have types for a data point. That will be what you're looking for, too.

Learning to make your own is very very worth it!


The decimal data type may be more suitable for you. It is a 'fixed'-point (as opposed to floating-point) data type. Though, you may not be able to store a number with an arbitrary number of digits, decimal type has its own limits.

You can read more on decimal type here:
MSDN: Decimal Structure[^]


这篇关于我可以使用什么数据类型来表示C#中的数字(20,6)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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