开发者

Storing zero after decimal point

Right now I'm working on a project using CFM and MSSQL.

I have a numbering data in a field. I've set the DATATYPE 开发者_运维百科as float.

example of the data:

3.1,3.2,3.3........,3.10, 3.11

My problem:

  1. it appeared that 3.10 doesn't exist. instead it comes as 3.1, which means I have two of 3.1 number.

  2. when i sort the data, it displayed as:

    3.1, 3.1, 3.11, 3.2, 3.3 .. .. etc.

I don't know what went wrong.

Please help.


If you need 3.1 and 3.10 to represent different values for whatever unholy abomination of math you are trying to accomplish, you will need to use a textual datatype like varchar.

As long as you are using a numeric type, SQL and every other programming platform will likely enforce the universal laws of mathematics where 3.1 and 3.10 are the same value.


If you want to store the precision as well, either make a new column to store that information, or store it as a string, which you can parse into a float before you need it as a number. Strings sort nicely, too.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜