用于存储从零开始的整数的MySQL数据类型?(MySQL Datatype for storing integers starting from Zero?)
我必须在数据库中存储格式为
0091
001
009751
009665
等的009665
,初始值基本上从零开始。 我试图使用int作为数据类型与无符号属性,但它似乎并没有工作。 哪种数据类型适合存储这种类型的值?I have to store
isdCodes
which is in format0091
001
009751
009665
etc. in the database, the initial will basically start from zero. i tried using int as datatype with unsigned attribute but it does not seems to work. which datatype is suitable for storing this type of value?
原文:https://stackoverflow.com/questions/6279723
最满意答案
对于钱, 总是小数。 这就是为什么它被创建。
如果数字必须正确相加或平衡,请使用十进制。 这包括任何财务存储或计算,分数或人们可能手动执行的其他数字。
如果数字的确切值不重要,请使用双倍速度。 这包括图形,物理或其他物理科学计算,其中已经有“数字的有效数字”。
For money, always decimal. It's why it was created.
If numbers must add up correctly or balance, use decimal. This includes any financial storage or calculations, scores, or other numbers that people might do by hand.
If the exact value of numbers is not important, use double for speed. This includes graphics, physics or other physical sciences computations where there is already a "number of significant digits".
相关问答
更多-
使用nextAfter(双启动,双向) : import java.math.*; public class a { public static void printNeighbours(BigDecimal start) { double result1 = start.doubleValue(); double result2; BigDecimal r1 = new BigDecimal(result1); int com = start.compareT ...
-
对于浮点数, n % 1 == 0通常是检查小数点之前是否有任何值的方法。 public static void Main (string[] args) { decimal d = 3.1M; Console.WriteLine((d % 1) == 0); d = 3.0M; Console.WriteLine((d % 1) == 0); } 输出: False True 更新:正如@Adrian Lopez所 ...
-
对于钱, 总是小数。 这就是为什么它被创建。 如果数字必须正确相加或平衡,请使用十进制。 这包括任何财务存储或计算,分数或人们可能手动执行的其他数字。 如果数字的确切值不重要,请使用双倍速度。 这包括图形,物理或其他物理科学计算,其中已经有“数字的有效数字”。 For money, always decimal. It's why it was created. If numbers must add up correctly or balance, use decimal. This includes a ...
-
试试这个我的朋友: double x1 = 10.5; double x2 = 5.666; label4.Text = String.Format("({0:N2}), ({1:N2})", x1, x2); 此表达式的结果: "(10.50), (5.67)" Try this my friend: double x1 = 10.5; double x2 = 5.666; label4.Text = String.Format("({0:N2}), ({1:N2})", x1, x2); R ...
-
你想从实数返回一个小数近似值? 例如0.3333~“1/3”。 你可以试试这个: #import
char out[20]; static char *fractApprox(double r, long d) { double atof(); int atoi(); void exit(); long m[2][2]; double x, startx; long maxden; long a ... -
Java:如果将十进制数为0的双精度型数字输出为整数格式(Java: how to output double-type number to integer format if its decimal is 0)[2022-12-25]
我不建议使用任何库: public static String parse(double num) { if((int) num == num) return Integer.toString((int) num); //for you, StackOverflowException return String.valueOf(num); //and for you, Christian Kuetbach } 将double转换为int将切断小数位。 随意将数字转换为任何你喜欢的字符串;) ... -
我建议在将它从数据库中取出之前将其转换为Real,它们的数据类型大致相同。 http://msdn.microsoft.com/en-us/library/ms173773.aspx I would suggest converting it to a Real before taking it from the database they are roughly the same datatype. http://msdn.microsoft.com/en-us/library/ms173773.aspx ...
-
您在格式化后乘以double ,因此您丢失了以前的格式,因此请在完成所有计算后,更改下面显示的代码,如下所示: double random = new Random().nextDouble(); double SP = 0.0 + (random * (7.0 - 0.0)); SP = Double.parseDouble(String.format("%.6f", SP)); //now do format You are multiplying with double after format ...
-
以十进制存储十进制数?(Storing decimal numbers in double? property using updatesourcetrigger as PropertyChanged)[2022-02-21]
如果你使用StringFormat=\{0:n\} ,你应该没问题。 例如:或者只是使用转换器。 例如: 计算结果因十进制或双重而不同[重复](Calculation result is different depending on decimal or double [duplicate])[2022-06-30]
双打不是一个精确的表示:有很多舍入和截断(但你确实得到了更大的范围)。 阅读: 每个计算机科学家应该知道的浮点运算 。 Doubles are not an exact representation: there is a lot of rounding and truncation (but you do get a much greater range). Reading: What Every Computer Scientist Should Know About Floating-Point Ar ...相关文章
更多- Groovy 数据类型详解
- MongoDB数据类型
- JS数据类型
- Java基本数据类型
- JSON 数据类型
- 快速掌握 redis 数据类型
- Python 基本数据类型
- 数据库设计 从零开始系列之一
- FreeMarker基本数据类型
- MongoDB学习(二):数据类型和基本概念
最新问答
更多- 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
- 如何通过引用返回对象?(How is returning an object by reference possible?)
- 矩阵如何存储在内存中?(How are matrices stored in memory?)
- 每个请求的Java新会话?(Java New Session For Each Request?)
- css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
- 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
- xcode语法颜色编码解释?(xcode syntax color coding explained?)
- 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
- 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
- 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
- 西安哪有PLC可控制编程的培训
- 在Entity Framework中选择基类(Select base class in Entity Framework)
- 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
- 电脑二级VF有什么用
- Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
- 金华英语角.
- 手机软件如何制作
- 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
- 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
- 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
- Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
- 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
- python的访问器方法有哪些
- DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
- 在Ruby中对组合进行排序(Sorting a combination in Ruby)
- 网站开发的流程?
- 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
- 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
- 透明度错误IE11(Transparency bug IE11)
- linux的基本操作命令。。。