Jump to content

Decimal field: Difference between revisions

From EPrints Documentation
mNo edit summary
 
Line 14: Line 14:


{| border="1" cellpadding="3" cellspacing="0"
{| border="1" cellpadding="3" cellspacing="0"
| name || default || description
! Name !! Default Value !! Required || Description || Notes
|-
|-
| '''integer''' || 16 || '''The maximum number of digits to store before the decimal point.'''
| '''integer''' || <tt>16</tt> || NO || The maximum number of digits to store before the decimal point. ||
|-
|-
| '''fractional''' || 2 || '''The number of digits to store after the decimal point.'''
| '''fractional''' || <tt>2</tt> || NO ||The number of digits to store after the decimal point. ||
|-
|-
|}
|}

Latest revision as of 21:03, 11 April 2023


Description[edit]

This field stores a decimal number. It could be used for prices or other numerical floating point numbers with a spefied amount of precision.

Inheritance[edit]

Additional Properties[edit]

As for Float fields except for:

Name Default Value Required Description Notes
integer 16 NO The maximum number of digits to store before the decimal point.
fractional 2 NO The number of digits to store after the decimal point.

Required Phrases[edit]

No additional phrases beyond those required for Float fields.

Database[edit]

Float fields are stored in the database as

fieldname DECIMAL(16,2)

The 16 and 2 will vary depending on what is set for integer and fractional respectively.

API[edit]

See API page.

Examples[edit]

Most basic example.

{
    name => 'total',
    type => 'decimal',
}

Set smaller number of digits before the decimal point

{
    name => 'price',
    type => 'decimal',
    integer => 8,
}

Set larger number of digits after the decimal point.

{
    name => 'latitude',
    type => 'decimal',
    fractional => 8,
}