⧼vector-jumptocontent⧽

Decimal field: Difference between revisions

From EPrints Documentation
Added decimal metadata field type
 
 
(One intermediate revision by the same user not shown)
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. ||
|-
|-
|}
|}
Line 31: Line 31:


== API ==
== API ==
See [[API:EPrints/MetaField/Float|API page]].
See [[API:EPrints/MetaField/Decimal|API page]].


== Examples ==
== Examples ==

Latest revision as of 21:03, 11 April 2023


Description

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

Additional Properties

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

No additional phrases beyond those required for Float fields.

Database

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

See API page.

Examples

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,
}