Decimal, Float and Double

Decimal vs Double vs Float

Decimal, Double, Float変数タイプは、値を格納する方法が異なります。 floatは単精度(32ビット)浮動小数点データ型、doubleは倍精度(64ビット)浮動小数点データ型、10進数は128ビット浮動小数点データ型であり、精度が主な相違点です。

Float – 32 bit (7 digits)

Double – 64 bit (15-16 digits)

Decimal – 128 bit (28-29 significant digits)

Decimal, Float and Double

The main difference is Floats and Doubles are binary floating point type and a Decimal will store the value as a floating decimal point type.これは10進数の浮動小数点型の値である。 したがって、Decimalはより高い精度を持ち、通常、高度な精度を必要とする金銭(金融)アプリケーションで使用されます。 しかし、性能的には、Decimalはdoubleやfloat型よりも遅いです。

Decimalは、FloatやDoubleがそれぞれの形式の精度内にある数字でさえも、すべての数字を正確に表現できないのに対し、10進数形式の精度内ではすべての数字を100%正確に表現することが可能です。

When To Use Decimal, Double, and Float

Decimal

In case of financial applications it is better to use Decimal types because it gives you a high level of accuracy and easy to avoid rounding errors

Double

Double types are probably the most normally used data type for real values, except handling money.Type: DATA Double 型のデータ型はおそらく実数値に最もよく使われるデータ型です。

Float

処理能力に対する要求が非常に高いため、グラフィックライブラリで主に使用され、また丸め誤差に耐えられる状況を使用します。

NEXT…String to DateTime

コメントを残す

メールアドレスが公開されることはありません。