Storing statistical data, do I need DECIMAL, FLOAT or DOUBLE?

后端 未结 6 1558
猫巷女王i
猫巷女王i 2020-12-02 15:07

I am creating for fun, but I still want to approach it seriously, a site which hosts various tests. With these tests I hope to collect statistical data.

Some of the

6条回答
  •  悲&欢浪女
    2020-12-02 15:55

    Unless you are storing decimal data (i.e. currency), you should use a standard floating point type (FLOAT or DOUBLE). DECIMAL is a fixed point type, so can overflow when computing things like SUM, and will be ridiculously inaccurate for LOG10.

    There is nothing "less precise" about binary floating point types, in fact, they will be much more accurate (and faster) for your needs. Go with DOUBLE.

提交回复
热议问题