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
seed Random number generator seed of this Element. Overrides default seeding behavior. no 0 1
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 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
  • und
  • ar-AE
  • ar-JO
  • ar-SY
  • hr-HR
  • fr-BE
  • es-PA
  • mt-MT
  • es-VE
  • bg
  • zh-TW
  • it
  • ko
  • uk
  • lv
  • da-DK
  • es-PR
  • vi-VN
  • en-US
  • sr-ME
  • sv-SE
  • es-BO
  • en-SG
  • ar-BH
  • pt
  • ar-SA
  • sk
  • ar-YE
  • hi-IN
  • ga
  • en-MT
  • fi-FI
  • et
  • sv
  • cs
  • sr-Latn-BA
  • el
  • uk-UA
  • hu
  • fr-CH
  • id
  • es-AR
  • ar-EG
  • ja-JP-u-ca-japanese-x-lvariant-JP
  • es-SV
  • pt-BR
  • be
  • is-IS
  • cs-CZ
  • es
  • pl-PL
  • tr
  • ca-ES
  • sr-CS
  • ms-MY
  • hr
  • lt
  • es-ES
  • es-CO
  • bg-BG
  • sq
  • fr
  • ja
  • sr-BA
  • is
  • es-PY
  • de
  • es-EC
  • es-US
  • ar-SD
  • en
  • ro-RO
  • en-PH
  • ca
  • ar-TN
  • sr-Latn-ME
  • es-GT
  • sl
  • ko-KR
  • el-CY
  • es-MX
  • ru-RU
  • es-HN
  • zh-HK
  • nn-NO
  • hu-HU
  • th-TH
  • ar-IQ
  • es-CL
  • fi
  • ar-MA
  • ga-IE
  • mk
  • tr-TR
  • et-EE
  • ar-QA
  • sr-Latn
  • pt-PT
  • fr-LU
  • ar-OM
  • th
  • sq-AL
  • es-DO
  • es-CU
  • ar
  • ru
  • en-NZ
  • sr-RS
  • de-CH
  • es-UY
  • ms
  • el-GR
  • he-IL
  • en-ZA
  • th-TH-u-nu-thai-x-lvariant-TH
  • hi
  • fr-FR
  • de-AT
  • nl
  • no-NO
  • en-AU
  • vi
  • nl-NL
  • fr-CA
  • lv-LV
  • de-LU
  • es-CR
  • ar-KW
  • sr
  • ar-LY
  • mt
  • it-CH
  • da
  • de-DE
  • ar-DZ
  • sk-SK
  • lt-LT
  • it-IT
  • en-IE
  • zh-SG
  • ro
  • en-CA
  • nl-BE
  • no
  • pl
  • zh-CN
  • ja-JP
  • de-GR
  • sr-Latn-RS
  • he
  • en-IN
  • ar-LB
  • es-NI
  • zh
  • mk-MK
  • be-BY
  • sl-SI
  • es-PE
  • id-ID
  • en-GB
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
  • pdgf.generator.MarkovChainText
  • pdgf.generator.AsReferenceChoice
  • pdgf.generator.WeightedListItem
  • pdgf.generator.DetailFromDate
  • pdgf.generator.BuildList
  • pdgf.generator.InsertIntoString
  • pdgf.generator.UUID
  • pdgf.generator.Probability
  • pdgf.generator.RandomString
  • pdgf.generator.Sequential
  • pdgf.generator.ConvertNumberToString
  • pdgf.generator.WeightedSubListItem
  • pdgf.generator.RandomListItems
  • pdgf.generator.Email
  • pdgf.generator.ActionDeleteIsAlsoUpdate
  • pdgf.generator.DoubleNumber
  • pdgf.generator.Permutation
  • pdgf.generator.Switch
  • pdgf.generator.ReferenceValue
  • pdgf.generator.ForFormula
  • pdgf.generator.PrePostfix
  • pdgf.generator.StaticValue
  • pdgf.generator.Hash
  • pdgf.generator.Padding
  • pdgf.generator.FormatString
  • pdgf.generator.DateTime
  • pdgf.generator.Id
  • pdgf.generator.LastChoice
  • pdgf.generator.MaskString
  • pdgf.generator.Null
  • pdgf.generator.AddRandomSeconds
  • pdgf.generator.RandomStringInRange
  • pdgf.generator.Formula
  • pdgf.generator.AbstractDecimal
  • pdgf.generator.FormatFloatingPoint
  • pdgf.generator.OtherFieldValue
  • pdgf.generator.RandomSentence
  • pdgf.generator.FormatNumber
  • pdgf.generator.Template
  • pdgf.generator.BigBenchReview
  • pdgf.generator.UpperLowerCase
  • pdgf.generator.For
  • pdgf.generator.Relative
  • pdgf.generator.RandomUniqeString
  • pdgf.generator.PermutationReference
  • pdgf.generator.UpdateActionType
  • pdgf.generator.FormatNumberAsDate
  • pdgf.generator.OldReferenceGeneratorDeprecated
  • pdgf.generator.DictList
  • pdgf.generator.ExtendedFormula
  • pdgf.generator.FormatDateAsNumber
  • pdgf.generator.If
  • pdgf.generator.GlobalRowNumber
  • pdgf.generator.LongNumber
  • pdgf.generator.UnsafeDistinct
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.6_#1486_b758 | 2016-05-24