When should I use double instead of decimal?

后端 未结 12 1746
Happy的楠姐
Happy的楠姐 2020-11-22 10:51

I can name three advantages to using double (or float) instead of decimal:

  1. Uses less memory.
  2. Faster because flo
12条回答
  •  鱼传尺愫
    2020-11-22 11:41

    A double values will serialize to scientific notation by default if that notation is shorter than the decimal display. (e.g. .00000003 will be 3e-8) Decimal values will never serialize to scientific notation. When serializing for consumption by an external party, this may be a consideration.

提交回复
热议问题