FormatFloatingPoint

FormatFloatingPoint

Takes a value from a sub-generator, treats it as 'double'-floating point value and formats it with the specified options.

Attributes
Name Description Required Min Max Allowed Values
name (Class)Name of this element. Used to identify plugin Class. Full name is required. Example: com.en.myPluginPackage.myPuginClass no 0 1
id Identification String of this element. May be used to uniquely identify a field within the children of an Element. no 0 1
Nodes
Name Description Required Min Max Allowed Values
format Content type: String
A format string describing how to format the number. Supported are class java.text.DecimalFormat (e.g. '#.000') and class java.util.Formatter (printf() sytle e.g.: '%.3d') syntax. If the format string contains a '%' symbol: first try to interpret format as Formatter style, with fall back to DecimalFormat. Else interpret format as DecimalFormat style with fall back to Formatter. Example: '%.3d' to format the number with 3 decimal places
Default: Unset (do not apply any special formatting to the number)
no 0 1
locale Content type: String
Locale to use. A locale defines the formatting rules for numbers, e.g what symbol to use as the decimal point and the thousand separator.
Examples: 'en-US', 'en-GB'. 'de-DE'
'Default is: 'us'
no 0 1
  • ar
  • ar-AE
  • ar-BH
  • ar-DZ
  • ar-EG
  • ar-IQ
  • ar-JO
  • ar-KW
  • ar-LB
  • ar-LY
  • ar-MA
  • ar-OM
  • ar-QA
  • ar-SA
  • ar-SD
  • ar-SY
  • ar-TN
  • ar-YE
  • be
  • be-BY
  • bg
  • bg-BG
  • ca
  • ca-ES
  • cs
  • cs-CZ
  • da
  • da-DK
  • de
  • de-AT
  • de-CH
  • de-DE
  • de-GR
  • de-LU
  • el
  • el-CY
  • el-GR
  • en
  • en-AU
  • en-CA
  • en-GB
  • en-IE
  • en-IN
  • en-MT
  • en-NZ
  • en-PH
  • en-SG
  • en-US
  • en-ZA
  • es
  • es-AR
  • es-BO
  • es-CL
  • es-CO
  • es-CR
  • es-CU
  • es-DO
  • es-EC
  • es-ES
  • es-GT
  • es-HN
  • es-MX
  • es-NI
  • es-PA
  • es-PE
  • es-PR
  • es-PY
  • es-SV
  • es-US
  • es-UY
  • es-VE
  • et
  • et-EE
  • fi
  • fi-FI
  • fr
  • fr-BE
  • fr-CA
  • fr-CH
  • fr-FR
  • fr-LU
  • ga
  • ga-IE
  • he
  • he-IL
  • hi
  • hi-IN
  • hr
  • hr-HR
  • hu
  • hu-HU
  • id
  • id-ID
  • is
  • is-IS
  • it
  • it-CH
  • it-IT
  • ja
  • ja-JP
  • ja-JP-u-ca-japanese-x-lvariant-JP
  • ko
  • ko-KR
  • lt
  • lt-LT
  • lv
  • lv-LV
  • mk
  • mk-MK
  • ms
  • ms-MY
  • mt
  • mt-MT
  • nl
  • nl-BE
  • nl-NL
  • nn-NO
  • no
  • no-NO
  • pl
  • pl-PL
  • pt
  • pt-BR
  • pt-PT
  • ro
  • ro-RO
  • ru
  • ru-RU
  • sk
  • sk-SK
  • sl
  • sl-SI
  • sq
  • sq-AL
  • sr
  • sr-BA
  • sr-CS
  • sr-Latn
  • sr-Latn-BA
  • sr-Latn-ME
  • sr-Latn-RS
  • sr-ME
  • sr-RS
  • sv
  • sv-SE
  • th
  • th-TH
  • th-TH-u-nu-thai-x-lvariant-TH
  • tr
  • tr-TR
  • uk
  • uk-UA
  • und
  • vi
  • vi-VN
  • zh
  • zh-CN
  • zh-HK
  • zh-SG
  • zh-TW
decimalPlaces Content type: Integer
Used to specify the precision of the calculation result.
Example: calculation raw result 3.644345345;
decimalPlaces<0: result -> 3.644345345 //unmodified (default)
decimalPlaces=2: result -> 3.64
decimalPlaces=3: result -> 3.642
decimalPlaces=36 <-max precision
Default: -1
no 0 1
gen Value Generator for this field yes 1 1
Sub-Attributes
Parent Name Description Required Min Max Allowed Values
decimalPlaces roundingMode Content type: String
Sets the rounding mode used to round numbers.
Default: HALF_EVEN
Possible values: [UP, DOWN, CEILING, FLOOR, HALF_UP, HALF_DOWN, HALF_EVEN, UNNECESSARY]
no 0 1
  • UP
  • DOWN
  • CEILING
  • FLOOR
  • HALF_UP
  • HALF_DOWN
  • HALF_EVEN
  • UNNECESSARY
decimalPlaces roundPlainValue Content type: Boolean
Round generated raw value to specified 'decimalPlaces'
If true : other generators will work with the rounded value.
If false: still round the value during 'toString()' but retain full precision for other generators using this generator's output, e.g., by reference or another computational generator.
Only available if 'decimalPlaces' parameter is >=0.
Default: true
no 0 1
  • true
  • false
  • 0
  • 1

Examples

  1. Format Double Number with German Locale and Two Decimal Places

    Generates random double numbers between -1000 and 1000. The generated double numbers are then formatted according to the German locale (see comma ',' as the decimal mark) and rounded to two decimal places using the default rounding mode 'HALF_EVEN'.

    Schema config for Format Double Number with German Locale and Two Decimal Places
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <!--
    /*******************************************************************************
    * Copyright (c) 2013, bankmark and/or its affiliates. All rights reserved.
    * bankmark UG PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
    ******************************************************************************/
    --><schema xmlns:doc="http://bankmark.de/pdgf/doc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="demo" xsi:noNamespaceSchemaLocation="structure/pdgfSchema.xsd">
      <!-- All data is derived from this starting seed.
           If this seed is the same, the generated data will the same on each
           computer/node/platform.
           Change this seed to generate a different data set.-->
      <seed>1234567890L</seed>
    
      <rng name="PdgfDefaultRandom"/>
    
      <!--Default Scale factor for all tables -->
      <property name="SF" type="double">1</property>
    
      <table name="FORMAT_FLOATING_POINT">
        <!-- if tables should scale with -SF command line argument.
             Specify your scaling formula here: -->
        <size>10 * ${SF}</size>
    
        <!--Format Double Number with German Locale and Two Decimal Places-->
          <!--
            Generates random double numbers between -1000 and 1000. The generated double numbers are then formatted
            according to the German locale (see comma ',' as the decimal mark) and rounded to two decimal places using the
            default rounding mode 'HALF_EVEN'.
          -->
          <field name="original_number" size="" type="NUMERIC">
            <gen_DoubleNumber>
              <minD>-1000</minD>
              <maxD>1000</maxD>
            </gen_DoubleNumber>
          </field>
          <field name="format_with_locale_places" size="" type="NUMERIC">
            <gen_FormatFloatingPoint>
              <locale>de-DE</locale>
              <decimalPlaces>2</decimalPlaces>
              <gen_OtherFieldValue>
                <reference field="original_number"/>
              </gen_OtherFieldValue>
            </gen_FormatFloatingPoint>
          </field>
          </table>
    </schema>
    
    Output for Format Double Number with German Locale and Two Decimal Places
    638.4153126668691|638,42
    -557.8296052558147|-557,83
    -745.0134077358066|-745,01
    665.4973873957078|665,50
    -196.42606757989654|-196,43
    -474.31264268159134|-474,31
    248.6970991879009|248,70
    -474.20440907721684|-474,20
    0.704382294637071|0.70
    241.26502724430793|241,27
  2. Format Double Number with German Locale and Non-Default Rounding

    Generates random double numbers between -1000 and 1000. The generated double numbers are then formatted according to the German locale (see comma ',' as the decimal mark) and rounded to two decimal places using the 'DOWN' rounding mode.

    Schema config for Format Double Number with German Locale and Non-Default Rounding
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <!--
    /*******************************************************************************
    * Copyright (c) 2013, bankmark and/or its affiliates. All rights reserved.
    * bankmark UG PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
    ******************************************************************************/
    --><schema xmlns:doc="http://bankmark.de/pdgf/doc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="demo" xsi:noNamespaceSchemaLocation="structure/pdgfSchema.xsd">
      <!-- All data is derived from this starting seed.
           If this seed is the same, the generated data will the same on each
           computer/node/platform.
           Change this seed to generate a different data set.-->
      <seed>1234567890L</seed>
    
      <rng name="PdgfDefaultRandom"/>
    
      <!--Default Scale factor for all tables -->
      <property name="SF" type="double">1</property>
    
      <table name="FORMAT_FLOATING_POINT">
        <!-- if tables should scale with -SF command line argument.
             Specify your scaling formula here: -->
        <size>10 * ${SF}</size>
    
        <!--Format Double Number with German Locale and Non-Default Rounding-->
          <!--
            Generates random double numbers between -1000 and 1000. The generated double numbers are then formatted
            according to the German locale (see comma ',' as the decimal mark) and rounded to two decimal places using the
            'DOWN' rounding mode.
          -->
          <field name="original_number" size="" type="NUMERIC">
            <gen_DoubleNumber>
              <minD>-1000</minD>
              <maxD>1000</maxD>
            </gen_DoubleNumber>
          </field>
          <field name="format_with_locale_places" size="" type="NUMERIC">
            <gen_FormatFloatingPoint>
              <locale>de-DE</locale>
              <decimalPlaces roundingMode="DOWN">2</decimalPlaces>
              <gen_OtherFieldValue>
                <reference field="original_number"/>
              </gen_OtherFieldValue>
            </gen_FormatFloatingPoint>
          </field>
          </table>
    </schema>
    
    Output for Format Double Number with German Locale and Non-Default Rounding
    749.2848022375979|749,28
    -282.26498837750796|-282,26
    514.6932045413268|514,69
    -875.8939883119749|-875,89
    891.8758908449572|891,87
    874.9411772810208|874,94
    684.2192264796929|684,21
    -172.22171545621154|-172,22
    184.5196872693241|184,51
    -473.4030668501923|-473,40
2.7-83fb0 | 2020-04-22