Converts a number to the indicated format (display format) and returns the resulting string. There is several forms to indicate the format:

  • If format is indicated, it takes the defined format.
  • If format is not indicated and locale is indicated, it takes the format based in a locale obtained for a country and variant.
  • If locale is not indicated, it uses the format of the user local.

1 number.format

<number.format
    format='format'
    maximumfractiondigits='maximumfractiondigits'
    minimumfractiondigits='minimumfractiondigits'
    lang='lang'
    country='country'
    variant='variant'
>
    <value /> !
</number.format>
Special characters of format:
Symbol Location Description
0 Número Dígito.
# Número Dígito, los ceros no relevantes no se muestran.
. Number Decimal separator.
- Number Minus.
, Number Separator of groups or blocks of digits.
E Number Separate the mantissa of the exponent in scientific notation.
; Subpattern limit Separate positives and negatives subpatterns.
% Prefix or suffix Multiply by 100 and it is shown as a percentage.
\u2030 Prefix or suffix Multiply by 1000 and it is shown as per thousand.
' Prefix or suffix It is used to place in inverted commas special characters in the prefix or suffix , for example "'#'#" format 123 as "#123". To indicate a simple quote sign as it is, two characters should be used, for example "# or''clock".

Exceptions

requires 1 arguments, received: 0

The function needs a entry value.

invalid number "..."

The value passed to the function is impossible to format since it is not a numeric value because it does not contain no numerical characters differents to the comma ',' and the point '.'...

user must be set for operations

An user is required to obtain its locale, in the case of not indicated format or language.

Example

Converts a number to the format "###,###.####", with 2 decimals. The number 987410 is represented according to this format and 2 decimals as 987,410.00.

Copy
<xsql-script name='number_format_sample1'>
    <body>

        <println>
            <number.format format='###,###.####' maximumfractiondigits='2' minimumfractiondigits='2'>
                987410
            </number.format>
        </println>

    </body>
</xsql-script>

Returns:

Copy
987,410.00

1.1 number.intValue

Returns the number in Integer format. It is useful to obtain the integer of a decimal for example.

<number.intValue>
    <number /> +
</number.intValue>
Example

The integer part of the number. In the example, the decimal value 83938.9383 will be obtained the integer number 83938.

Copy
<xsql-script name='number_intValue'>
    <body>
        <println>
            <number.intValue>
                <number>83938.9383</number>
            </number.intValue>
        </println>
    </body>
</xsql-script>

Returns:

Copy
83938