0

Drupal has several types of numeric fields:

  • integer
  • float
  • decimal

I know, that decimal field is used to store numeric data with high accuracy. But when it may be necessary in real project? Are there any good examples?

0

1 Answer 1

1

Here's a link to an explanation of Drupal's different number types (integer vs. decimal vs. float) with some examples. Basically, it breaks down as follows:

  • Integer: You're storing numbers without fractional digits (e.g. a field that stores a product stock quantity, XX units)
  • Decimal: You're storing numbers with a fixed amount of fractional digits. (e.g. a field that stores a price, $XXX.YY)
  • Float: You're storing numbers with a variable amount of fractional digits. (e.g. a field that stores latitude/longitude coordinates, XX.XXXXXXX..., YY.YYYYY...)

Also of note is the underlying data structures of integer/decimal/float that gets stored in the database. See Fixed point vs. Floating point for some discussion on the differences.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.