Decimal field

From EPrints Documentation
Revision as of 21:17, 10 April 2023 by Drn@ecs.soton.ac.uk (talk | contribs) (Added decimal metadata field type)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

EPrints 3 Reference: Directory Structure - Metadata Fields - Repository Configuration - XML Config Files - XML Export Format - EPrints data structure - Core API - Data Objects


Metadata Fields: Arclanguage - Base64 - Bigint - Boolean - Compound - Counter - Dataobjref - Date - Decimal - Email - Fields - Float - Id - Idci - Image - Int - Itemref - Keywords - Langid - Longtext - Longtext_counter - Multilang - Multipart - Name - Namedset - Pagerange - Recaptcha - Recaptcha3 - Relation - Search - Secret - Set - Storable - Subject - Subobject - Text - Time - Timestamp - Url - Uuid


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 description
integer 16 The maximum number of digits to store before the decimal point.
fractional 2 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,
}